ADODB Connection, Type Mismatch

mjdemaris

Working on it...
Local time
Yesterday, 22:47
Joined
Jul 9, 2015
Messages
426
Hi all.

I'm toying around with (trying to) ado connections and here's what I've got:

Code:
Public Sub OpenDB_ADO()
    Dim conn As ADODB.Connection
    Dim strdb As String
    
    Stop
    On Error GoTo ErrHandler
    
    strdb = CurrentProject.Path & "\sw101.accdb"
    Set conn = New ADODB.Connection
    
    With conn
        .Provider = "Microsoft.ACE.OLEDB.12.0;"
        .Mode = adModeReadWrite
        .ConnectionString = "Data Source=" * strdb
        .Open
    End With
    
    If conn.State - adStateOpen Then
        MsgBox "Connection was opened."
    End If
    
    conn.Close
    Set conn = Nothing
    MsgBox "Connection was closed."
    
ErrHandler:
    MsgBox Err.Number & ": " & Err.Description
End Sub

The error comes on the "ConnectionString=" line.

I've gone through a bunch of Reference combinations and haven't found the answer yet.

I've got:
15.0 object lib
ado ext. 6.0 for DDL and Security (probably don't need that)
ActiveX Data Obj 6.1 lib
Scripting Runtime
Script Control 1.0
16.0 obj lib (had to add this one for FileDialog to work)

Thanks!
 
Can't tell you how many times the modern keyboard (that puts & and * next to each other) has caused me that same exact error message when I was building an SQL string that should have been concatenated - but wasn't.
 
"Modern" keyboard? Don't tell me you're from the typewriter era, lol. When I was a kid, I actually saw one and used one. Actually, I think I used one while I was in school for a short time.

Doc, I like your tag: "Certified grandpa". My oldest, 17, asked me the other day: Dad, how would you feel about being a grandpa in the next 5 years? My jaw almost dropped! My youngest is 6, and I'm a hair over 40! I have to say, like you, I'd be proud of it!
 

Users who are viewing this thread

Back
Top Bottom