Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP can't connect to Access DB. Why not? 1

Status
Not open for further replies.

WuCOng

Technical User
Apr 20, 2001
37
0
0
GB
Using this string (which I was given by my university):

Set myConn=Server.CreateObject("ADODB.Connection")
myDB="Driver={Microsoft Access Driver(*.mdb)};DBQ=db1.mdb"

I can't access this DB. I get this error:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

The ASP page and DB are on my home machine. I'm not on the net at home, I'm just trying to create and test my ASP pages.

CAn anyone help?
 
Your pages must be on the same server as the connection.

Your path of your database also should be full (ie. c:\database\db1.md).

YOu need to create a Personal Web Server on your own pc to work with then change the path of the database to match the server.

Which operating system are you on at home? You can download the Personal WEb Server if you need to. Mary :)

Rule 1: Don't sweat the small stuff.
Rule 2: EVERYTHING is small stuff!! X-)
 
I have had problems connecting to databases too. The only way i can connect os by using this script:

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\db\dbname.mdb")

Just change the \db\dbname.mdb part, leave everything else the same.


JoeM6
JPMJR11@aol.com
 
Thanks Mary(Telsa). I have PWS installed with Win98. ASP code works fine usually, it's just the database stuff that doesn't.

I've tried every permutation of the database path but to no avail. The ASP page and database are in the same folder. Does the direction of the slash (/ or \) matter?

I've been wrestling with this for days. No one on the web I've asked knows anything (except you :) )
 
You might want to create a DSN connection. Go to Control Panel and select 32bitOBDC. Then select System DSN. Click Add and select the Access driver (hopefully, it is 4.00 or greater!). Click finish. Then another dialog box will pop up and in Data Source Name, give any name you want for this connection (I always call it same name as database to remove confusion) and a description (if you'd like). Then click Select and find your database. Once you have clicked OK, you have created a DSN connection. Then in your ASP when you open the database, the way you code it is

<% set oRS = server.createobject(&quot;ADODB.recordset&quot;)
oRS.open &quot;Select * From {here you would type in the table name you want to connect to]&quot;, &quot;DSN={here you would type in the DSN connection name you just made}&quot;
oRS.Movefirst
%>

Now you can use this to pull the data in and place it where you need it. I'm learning from a great book called Beginning ASP Database from Wrox. It's a great help!

Mary :)

Rule 1: Don't sweat the small stuff.
Rule 2: EVERYTHING is small stuff!! X-)
 
You are a star Mary. It worked! Fantastic.

If I create the ASP pages and then shift it all to a webserver I'll only have to alter the connection string to point to the nwe location of the database won't I?

Or is that too easy? :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top