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

Help. Error reading from access db.

Status
Not open for further replies.

lck092580

Programmer
Jun 19, 2002
440
CA
Help. I'm trying to do a simple retrieval from an access db but I'm getting the following error.

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.
/displaydb.asp, line 10

any ideas?.. it's definitly not in use.. the db is in the same directory as the .asp file.

Thanks in advance.
 
I did already... i've opened it up and added a few records then saved.. then closed.
 
I assume that what you mean by "closed" is that you are closing off the recordset. With that in mind and since the database is not ReadOnly, are you closing the data connect object after adding records? If not, are you using the same connect object? If you haven't closed one and you are trying to open another, that could be your problem.
 
Thanks for the continuing help BarkingFrog. I really appreciate it. I actually got the code out of a text book (i'm learning how to use asp to connect to an sql db i have set up locally). I followed the instructions of the book. Here's the code:

<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include virtual=&quot;/adovbs.inc&quot;-->
<%
'Open up a connection to our Access database
'We will use a DSN-less connection.
Dim objConn
Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
objConn.ConnectionString = &quot;DSN=Dummy.dsn&quot;
objConn.Open

'Create a recordset object instance and retrieve the information
'from the Friends table.
Dim objRS
Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
objRS.Open &quot;Friends&quot;, objConn, , , adCmdTable

'Display the contents of the Friends table
Do While Not objRS.EOF
Response.Write &quot;<B>&quot; & objRS(&quot;Name&quot;) & &quot;</B><BR>&quot;
Response.Write objRS(&quot;StreetAddress&quot;) & &quot;<BR>&quot;
Response.Write objRS(&quot;City&quot;) & &quot;, &quot; & objRS(&quot;State&quot;)
Response.Write &quot;<BR>&quot; & objRS(&quot;Zip&quot;) & &quot;<BR>&quot;
Response.Write objRS(&quot;PhoneNumber&quot;) & &quot;<P><HR><P>&quot;

'Move to the next row in the Friends table
objRS.MoveNext
Loop


'Clean up our ADO objects
objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing
%>

I made a db called &quot;Dummy.mdb&quot; in access (the file is saved in the same directory as this .asp file).. then followed the book's instructions to get the correct odbc drivers installed.. and it just isn't working. I actually gave up on this three weeks ago but started to look @ it again today. Any ideas?
 
Ok, I see your problem. Your code is using a DSN. You either need to create a DSN for your current code or you need to write an actual connect string to use that will directly connect to your database within your code. You aren't even connecting to the database. Do you have a preference?

Here is the connect code for making a direct connection without using a DSN:

In place of: objConn.ConnectionString = &quot;DSN=Dummy.dsn&quot;
objConn.Open&quot; use this---

strConString=&quot;DBQ=(path to Dummy.mdb);DefaultDir=DBQ=(path to Dummy.mdb);Driver=(Microsoft Access Driver (*.mdb));DriverId=25;FIL=MS Access;&quot;

objConn.Open strConString


--this will give you a connection. Otherwise, you could create a DSN called Dummy.dsn and you shouldn't have to change any of your current code.
 
But I did create a DSN called Dummy.dsn. I think the previous error msg meant that it found the db but couldn't open it. I tried putting what u typed in:

dim strConString
strConString=&quot;DBQ=c:\inetpub\ Access Driver (*.mdb));DriverId=25;FIL=MS Access;&quot;

objConn.Open strConString

but now i'm getting a:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/displaydb.asp, line 12

Thank you for helping barkingfrog(weird name). Really appreciate it. I come from a java programming background vbscript seems very easy.. but this driver thing is just annoying. Thanks.

T
 
Ooooohhhhh...I think I see another problem--:)

Replace this:

objRS.Open &quot;Friends&quot;, objConn, , , adCmdTable

with this:

Dim strSQL
strSQL = &quot;Select * from Friends&quot;
objRS.Open strSQL,objConn,2,2


Does that help?
 
Ops sorry. I've been testing this with other db called friends that has contacts of ppl. It's still not working.. here's the code:

<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include virtual=&quot;/adovbs.inc&quot;-->
<%
'Open up a connection to our Access database
'We will use a DSN-less connection.
Dim objConn
Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
dim strConString
strConString=&quot;DBQ=c:\inetpub\ Access Driver (*.mdb));DriverId=25;FIL=MS Access;&quot;

objConn.Open strConString

'Create a recordset object instance and retrieve the information
'from the Friends table.
Dim objRS
Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)

Dim strSQL
strSQL = &quot;Select * from Friends&quot;
objRS.Open strSQL,objConn,2,2

'Display the contents of the Friends table
Do While Not objRS.EOF
Response.Write &quot;<B>&quot; & objRS(&quot;Name&quot;) & &quot;</B><BR>&quot;
Response.Write objRS(&quot;StreetAddress&quot;) & &quot;<BR>&quot;
Response.Write objRS(&quot;City&quot;) & &quot;, &quot; & objRS(&quot;State&quot;)
Response.Write &quot;<BR>&quot; & objRS(&quot;Zip&quot;) & &quot;<BR>&quot;
Response.Write objRS(&quot;PhoneNumber&quot;) & &quot;<P><HR><P>&quot;

'Move to the next row in the Friends table
objRS.MoveNext
Loop


'Clean up our ADO objects
objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing
%>

Here's the error msg:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/displaydb.asp, line 12

Frog, even if we don't get this resolved I want u to know that I really appreciate your help.

= )
 
I'm happy to help. Just hope we can solve this for you.

Anyway......I'm a little confused.....your database is called &quot;Friends&quot;? What is the name of the database and the name of the table you are trying to get the information from?
 
well.. at first i, following the book's instructions, made a friend db where i put some contacts in. Then i copied what was in the book and i started getting error msgs. So i thought maybe i did this incorrectly so i created another db called dummy.mdb and tried it. Still didn't work so i thought it's probably not the db's fault.. it's something else.

So rite now i have two dbs in my c:\inetpub\ directory. The book's first chunk of code where it doesn't use a dsn didn't work.. so i tried the second part where it guides me step by step to create a dsn and change the code to use the dsn but it still doesn't work. I'm baffled. It's a good thing i'm just learning this for fun. Vbscript seems very easy after doing so much java @ school.. but this driver stuff is @#$@#$ off. = )

Thanks again froggy..

T
 
Looks to me like you just aren't finding the database. In your code write the following right after &quot;objConn.Open strConString&quot;

Response.Write &quot;Frog&quot;
Response.End


Tell me what your results are.
 
Hehe.. nice way to troubleshoot (what I would do if i was debugging in java).

I'm still getting the same error msg.. but if i do this instead:

<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include virtual=&quot;/adovbs.inc&quot;-->
<%
'Open up a connection to our Access database
'We will use a DSN-less connection.
Dim objConn
Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)

Response.Write &quot;Frog&quot;
Response.End

dim strConString
strConString=&quot;DBQ=c:\inetpub\ Access Driver (*.mdb));DriverId=25;FIL=MS Access;&quot;
--snip--

it works!.. meaning i see the frog output.
= )
 
this is wat happens if i do this instead:

Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
dim strConString
strConString=&quot;DRIVER={Microsoft Access Driver (*.mdb)};&quot; & _
&quot;DBQ=C:\inetpub\
objConn.Open strConString

----error msg below---------

Error Type:
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 0x6f4 Thread 0x8e0 DBC 0x13f900c Jet'.
/displaydb.asp, line 13

could it be my drivers?.. gosh this is getting complicated..
= )
T
 
strConString=&quot;DBQ=c:\inetpub\ Access Driver (*.mdb)};DriverId=25;FIL=MS Access;&quot;

Type this connection string into the place of the other. It includes &quot;{}&quot; in place of &quot;()&quot; and this may make a difference. This was my mistake.....ooops!
 
hmm.. still the same.. here's what i have now:

dim strConString
strConString=&quot;DBQ=c:\inetpub\ Access Driver (*.mdb)};DriverId=25;FIL=MS Access;&quot;

objConn.Open strConString

----------the error msg is:----------

Error Type:
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 0x6f4 Thread 0x820 DBC 0x1404c34 Jet'.
/displaydb.asp, line 12

I think the problem has to do with windows.. the coding's probably correct but maybe it's how the drivers in my windows is set up (i'm using win2k). Thanks for your help froggy.. really appreciate it.. I'm going to leave work and maybe start fresh (i'm reinstalling the stuff soon).

Thanks again.

Terence appreciate's froggy's help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top