469,643 Members | 1,792 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

Retrieving data from ACCESS database

Hi,
I have a sample ASP code which should get the records from a table in ACCESS database. However, while running the page I am getting the following error:

"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."

The code which I have is:

<%
Dim rs
Set rs = Server.CreateObject ("ADODB.Recordset")

rs.Open "My Table", "DSN=My Database"

While Not rs.EOF
Response.Write "ID : " & rs("id") & "<br>"
Response.Write "First Name : " & rs("first_name") & "<br>"
Response.Write "Last Name : " & rs("last_name") & "<br>"
Response.Write "<br>"

rs.MoveNext
Wend

rs.Close
Set rs = Nothing
%>



Can anyone please help me rectify this??

Thanks,
deep2389
Sep 24 '07 #1
2 3128
shweta123
692 Expert 512MB
Hi,

Please check if the table you are updating or database(.mdb file) is opened
previously. Close the database in order to remove the error.
Sep 24 '07 #2
jhardman
3,406 Expert 2GB
deep,

do you have a database connection object? (it isn't in the code listed above) I think your "set rs..." line might be technically incorrect without it. The syntax should be something like this:
Expand|Select|Wrap|Line Numbers
  1. Dim rs, conn
  2.     set conn = server.createobject("ADODB.Connection")
  3.     conn.open "DSN=myDatabase"
  4.     Set rs = Server.CreateObject ("ADODB.Recordset")
  5.     rs.Open "SELECT * FROM myTable", conn
I always do something more like this. I realize that there are potentially many different ways to do this, but I get few errors connecting this way. Let me know if this helps.

Jared
Sep 24 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Dave Hopper | last post: by
2 posts views Thread by RSH | last post: by
1 post views Thread by jimmyfo | last post: by
11 posts views Thread by Nemisis | last post: by
1 post views Thread by Chris | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.