Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    OLEDB Connection Problem

    Hi all,

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

    Code:
    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-

    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-
    Code:
    Microsoft JET Database Engine error '80040e4d' 
    
    Cannot start your application. The workgroup information file is missing or opened exclusively by another user.
    Thoughts?

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Try this:
    Code:
    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

  • #3
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Brandoe85
    Try this:
    Code:
    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.
    Code:
    set RS = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM [users] WHERE [userName] = '" & loginName & "' AND [userPassword] = '" & loginPW & "'" 
    RS.CursorType = 3 
    RS.Open strSQL, conn

  • #4
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Nevermind, got it

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •