Computer Learning Zone CLZ Access Excel Word Windows

It is strange that only extraordinary men make the discoveries, which later appear so easy and simple.

-Georg C. Lichtenberg
 
Home   Courses   Seminars   Templates   TechHelp   Fast Tips   Forums   Help   Contact   Join   Order   Logon  
 
Home > Forums > ASP
 
Active Server Pages Forum


Back to Active Server Pages Forum
 

Connect to Access Database Upload Images   Link  
Kevin Robertson 
2 years ago
I am attempting to connect to my database using ASP.Net in Expression Web. I am using the following code:

dim conn
dim rs
conn = server.createobject("ADODB.Connection")
conn.open ("StoreDSN")
rs = server.createobject("ADODB.Recordset")
rs.activeconnection = conn
rs.open ("SELECT ProductID, ProductName FROM ProductT")
while not rs.eof
  response.write (rs("ProductName"))
  rs.movenext
end while


When I navigate to the page I get the following result:
System.__ComObject

Repeating for every record in the database. Any ideas?
Richard Rost
2 years ago
I've never liked using DSNs. Try this instead:

DatabasePath = "/full/path/to/your/database/whatever.mdb"
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider="Microsoft.Jet.OLEDB.4.0;"
Conn.Open Server.MapPath(DatabasePath)


You shouldn't need the rs.ActiveConnection line.

And remember you don't need parentheses around statements that aren't functions and don't return a value. For example:

response.write rs("ProductName")

You don't need parens around that because you aren't returning a value from it.
Kevin Robertson
2 years ago
Thank Richard, finally got it working. Initially ran into the same problem until I made the followong change:

response.write (rs("ProductName").Value)

Set is apparently no longer supported, so had to leave it off.
Tried without the parentheses and got on error message.
Compiler Error Message: BC30800: Method arguments must be enclosed in parentheses.

Thank you once again and keep up the great work you are doing.
Richard Rost
2 years ago
Well that's news to me. I have done very little with ASP.NET. A few pages here and there to do specific things not supported in Classic ASP (like file uploads).

This thread is now closed. If you wish to comment, start a NEW discussion, below.
 


Back to Active Server Pages Forum Comments
 

Start a NEW Conversation
 
Only students may post right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.
 
Subscribe
 
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn