Link to home
Start Free TrialLog in
Avatar of fritz_the_blank
fritz_the_blankFlag for United States of America

asked on

ASP Access Connection

To connect to an Access database back end in an ASP, I use the following code:

dim conn
set conn =Server.CreateObject("ADODB.Connection")
conn.Open "DSN=testconnect","admin","admin"

dim rs 'record set
dim sql 'sql statement

set rs = Server.CreateObject("ADODB.RecordSet")
sql = "Select * from Addresses"

rs.Open sql, conn

"testconnect" is configured as an ODBC connection in the "ODBC Data Sources" control panel with the Access driver.

When I run this on my Windows 98 machine using personal web server, it works perfectly. However, when I place all of the files (including the database) on an NT Server running IIS and create the appropriate ODBC profile, I get the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

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

Any other ASP in this directory runs fine as long as it does comprise a data connection.

Any advice would be greatly appreciated.

Fritz the Blank

ASKER CERTIFIED SOLUTION
Avatar of sharmon
sharmon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Marine
Marine

conn.Open "DSN=testconnect","admin","admin"

make sure that dsn name that you created points to that database, also check the name correctly. have you explicitly set the pws to admin ? if not remove it althogether.

conn.Open "DSN=testconnect","admin",""
Hey Fritz,

1. Check that it is a
SYSTEM DSN and not a USER DSN

2. Check the dsn name for case sensitivity:
"TestConnect" <> "testconnect"

Cheers, Paul
Hi Fritz the Blank,

Try the below scripts:

1.
<%
set conn=Server.CreateObject("ADODB.Connection")
fpath="DBQ="&Server.MapPath("/databasename.mdb")
dpath="Driver={Microsoft Access Driver (*.mdb)};"
conn.Open dpath&fpath
set rs=Server.CreateObject("ADODB.Recordset")    
%>

2.
This code need to set the DSN.
<%      
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "DSN=supercorridor;UID=username;PWD=password"
set rs=Server.CreateObject("ADODB.Recordset")    
%>

good luck

by
skhan88
Avatar of fritz_the_blank

ASKER

Comment accepted as answer
This not only allowed the project to function on NT but it also sped things up somewhat.

Thanks a bunch!

Fritz the Blank
Glad I could help, I never use DSN's anymore, the ole connection string is easier to administrate and as a plus it's a bit faster....take care.

Regards,
Shannon Harmon