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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript (ASP): Connecting to an Access DB

Status
Not open for further replies.

flanakin

Programmer
Mar 21, 2000
158
0
0
US
For some reason I am not able to connect to my database. Here's the code:

Set DBConnect = Server.CreateObject("ADODB.Connection")
DBConnect.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=c4"

The database (c4.mdb) is in the same directory as the file using the code. And, the error is:

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x604 Thread 0x6cc DBC 0x2133fc4 Jet'.

Any help is appreciated. Thanks. [sig]<p>Cid<br><a href=mailto:ciddivine@yahoo.com>ciddivine@yahoo.com</a><br><a href= > </a><br> [/sig]
 
Cid,

Did you setup a data source to point to the database? You do this in the Control Panel.

Here's what I use to connect to Databases in ASP. This may not be the best way to do it, but it works for me.

Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
objConn.Open &quot;DSN=C4;UID=administrator;PWD=admin;&quot;, &quot;&quot;, &quot;&quot;

This should get you going... [sig]<p>Steve<br><a href=mailto:tribesaddict@swbell.net>tribesaddict@swbell.net</a><br><a href= > </a><br> [/sig]
 
Here's the error I get when I use the DSN:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data. [sig]<p>Cid<br><a href=mailto:ciddivine@yahoo.com>ciddivine@yahoo.com</a><br><a href= > </a><br> [/sig]
 
You probably have it open in Access like in Design mode or something. Be sure you close Access before you try to run the code. [sig]<p>Steve<br><a href=mailto:tribesaddict@swbell.net>tribesaddict@swbell.net</a><br><a href= > </a><br> [/sig]
 
Access isn't open. The only place I even access it, is in InterDev, where it shows up on the list of files in the directory. But, I have it removed from my local directory, so there shouldn't be any problems. It's just recognizing it's existence. [sig]<p>Cid<br><a href=mailto:ciddivine@yahoo.com>ciddivine@yahoo.com</a><br><a href= > </a><br> [/sig]
 
Try this:

dim strDB
dim cn

strDB = &quot;PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:\iweb\dbs\merchant.mdb; Jet OLEDB:Database

'open the connection
Set cn = Server.CreateObject(&quot;ADODB.Connection&quot;)
cn.ConnectionString = strDB
cn.Open

This works for me.

Dennis [sig][/sig]
 
Remove it from Interdev. Interdev makes it read only. Put it on the server and use a Local DSN to connect to it. You also need a DSN set up on the server pointing to it.

ASP is too dumb to find it sometimes. I can not use a DSN-less connection either. [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top