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

ADODB Connection error

Status
Not open for further replies.

MrPeds

Programmer
Jan 7, 2003
219
0
0
GB
Hi,

I am writing some simple code to connect to an Access database, however when i try the following code I get this error message:

Dim cn

Set cn = Server.CreateObject("ADODB.Connection")
cn.Open("myDSN")

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.

I am using WIndows 2k, with IIS and am logged in as the Administrator. I have enabled anonymous access to the default user directory.

Any help is appreciated!

MrPEds
 
'I would lose the DNS and go for the jet provider.
'1) Change "tblYourTable" on line 3 to the table you are accessing
'2) Change "c:\dbYourDataBase.mdb" on line 4 to the database path and name you want to open.
'3) Change "strYourField" To the field you want obtain.
'------------------------------------------------
Dim objRecordSet
Set objRecordSet = Server.CreateObject("ADODB.RecordSet")
objRecordSet.Source = "SELECT * FROM tblYourTable"
objRecordSet.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\dbYourDataBase.mdb;"
objRecordset.CursorLocation = 3
objRecordset.LockType = 3
objRecordset.CursorType = 0
objRecordset.Open

'Code to display data
While (NOT objRecordset.EOF)
Response.Write(objRecordSet.Fields("strYourField").Value)
objRecordset.MoveNext
Loop

objRecordset.Close
Set objRecordSet = Nothing
 
Thanks for this PJames,

It wasn't actually an error with my code, but a permissions problem.

Basically I had to give the IUSR user account permissions to anonymously access the files found from
Control Panel > Administrative Tools > Computer Mgmt > Users.

I would imagine this would be different for people who do not log in as 'Administrator'

Hope this is of use to people,

MrPEds
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top