...

View Full Version : OLEDB Connection Problem



Burnout
01-21-2005, 09:01 PM
Hi all,

I've been using the following code to connect to a database-



Sub vbOpenConn()
dbLocation = Server.MapPath("mydb.mdb")
set conn = Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0;"
conn.Open dbLocation
End Sub

After talking with one of the IT guys here at work, they're questioning how secure OLEDB is vs. ODBC. I can't find any hard evidence that OLEDB is less secure than ODBC, but I said that at the very least I could put a password on the database.

Now I'm feeling kinda noobish here, but I honestly am unsure how to do this. I put a password on the Access database (through Access), but when I connect I got an error I wasn't expecting. Here is how I modified the above code-



Sub vbOpenConn()
dbLocation = Server.MapPath("projects.mdb")
set conn = Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0;Data Source=projects.mdb;User Id=;Password=mypassword;"
conn.Open dbLocation
End Sub

And the error I get-


Microsoft JET Database Engine error '80040e4d'

Cannot start your application. The workgroup information file is missing or opened exclusively by another user.

Thoughts?

Brandoe85
01-21-2005, 10:05 PM
Try this:


Sub vbOpenConn()
Dim conn
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=projects.mdb;" & "Jet OLEDB:Database Password=yourPassword;"
End Sub

Burnout
01-21-2005, 10:55 PM
Try this:


Sub vbOpenConn()
Dim conn
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=projects.mdb;" & "Jet OLEDB:Database Password=yourPassword;"
End Sub

I'm afraid that didn't do it. Now I get a page cannot be displayed error instead of the previous error. This leads me to believe that perhaps the connection is being established, but I'm getting errors when trying to make a recordset.

Here is the snippet of code on the following page that would create a recordset.


set RS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM [users] WHERE [userName] = '" & loginName & "' AND [userPassword] = '" & loginPW & "'"
RS.CursorType = 3
RS.Open strSQL, conn

Burnout
01-26-2005, 08:50 PM
Looks like that bit of code worked after all. I think the server must have been caching the old pages because all of a sudden it just started working.

Thanks for the help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum