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!

ODBC connection error...

Status
Not open for further replies.

Atomsk

MIS
Jun 3, 2003
60
0
0
US
"The database has been placed in a state by an unknown user that prevents it from being opened or locked."


The above is the error that I frequently get when some script of mine runs that creates ADO connections. Apparently, the reason is that I'm creating the connection implicitly (as opposed to explicitly)...too bad I don't know what the difference is. The code snippet is as follows:




'implicit connection w/ recordset (I think)

Dim db_00, rs_00

Set db_00 = CreateObject("ADODB.Connection")

db_00.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\Program Files\Access Pages\GAPS_db01\GAPS_db01.mdb" & ";UID=;PWD="

Set rs_00=db_00.execute("SELECT * FROM recordsCurrentYear")

"
"
"

rs_00.Close
db_00.Close




Any help is greatly appreciated. Thanks.


 
I don't think you're quite closing the connection properly. The follow coding is some I used in an ASP to connect to a database, you'll have to change bits, like the database name. I think this is the same sort of thing that you're wanting to do?

' create an ADO object to represent the connection to the database
Set adoDataConn = Server.CreateObject("ADODB.Connection")

' Database connection info and driver
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("[db_name].mdb") & ";"

' Open the database connection
adoDataConn.Open strConnectionString

strQuery = "SELECT * FROM [table_name]"
Set objEmployeesRS = adoDataConn.Execute(strQuery)
.
.
.
objEmployeesRS.close
Set objEmployeesRS = Nothing

' Once you have finished with a connection you should close it
adoDataConn.Close
Set adoDataConn = Nothing

Hope this solves your error?

[PC2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top