Forum Moderators: open

Message Too Old, No Replies

access db connection string

         

webguy262

7:40 pm on Jun 15, 2009 (gmt 0)

10+ Year Member



Moved a site from one host to another and the access connection string no longer works.

Here is the old code...

<%
Dim objConn
Dim adUseClient
adUseClient = 3
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open Session("totaltecconnect")
objConn.CursorLocation = adUseClient
%>

Here is the error...

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

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

/admin/inc/TT_ConnectCursorLoc.asp, line 6

TIA for any suggestions!

mattur

7:58 pm on Jun 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You haven't included the connection string in your snippet. It appears to be stored in Session("totaltecconnect"). You probably just need to update the path for the new hosting, something like:

MyConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\PathTo\MyDatabase.mdb;User Id=admin;Password=;"

webguy262

8:39 pm on Jun 15, 2009 (gmt 0)

10+ Year Member



Yes, that's what I thought I had to do.

So I put up a file to get the path to the dbase and it comes back:

\\HOSTING\DFS\20\1\1\9\2053580911\user\sites\totaltec.com\www\path.asp

How would I configure the source path from that?

The dbase is in /www/

mattur

11:29 am on Jun 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's a UNC path, try it and see if it works.

webguy262

11:37 am on Jun 16, 2009 (gmt 0)

10+ Year Member



I tried that... no go. I'll post the error message in a few minutes.

webguy262

12:35 pm on Jun 16, 2009 (gmt 0)

10+ Year Member



Made a little progress I think.

Using this...

<%
Dim objConn
Dim adUseClient
adUseClient = 3
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\\HOSTING\DFS\20\1\1\9\2053580911\user\sites\totaltec.com\www\totaltec.mdb"
objConn.CursorLocation = adUseClient
%>

I get this error...

ADODB.Recordset error '800a0e7d'

The connection cannot be used to perform this operation. It is either closed or invalid in this context.

/index.asp, line 71

Line 71 is...

objrs.open strsql, objconn

mattur

12:54 pm on Jun 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you opened the connection object? You don't have to set the connection string property explicitly. For example (nb: I've changed strings to example.com):

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\\HOSTING\DFS\20\1\1\9\2053580911\user\sites\example.com\www\example.mdb"

It's recommended to use an OLEDB connection string instead of ODBC with Access (or even better, use SQL Server):

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\HOSTING\DFS\20\1\1\9\2053580911\user\sites\example.com\www\example.mdb"

BTW: you can use Server.MapPath("/example.mdb") to easily map a virtual path to a file path.

Try doing a nice simple ASP page to open and query the database on your PC, if you have IIS installed locally. When it's working, transfer it to your server and then try new connection string. Check with your host if you're still having problems, I imagine they will have done this before... Let us know the solution when resolved.

webguy262

1:18 pm on Jun 16, 2009 (gmt 0)

10+ Year Member



Not opening the connection was the problem.

Thanks!