Greetings all,
How can I use ADODB to return all tables in an access DB chosen by the
user?
I'm able so far to select the DB file and build up my connect string,
but I would like to offer a list of tables withing the DB and allow
the user to choose.
Is this possible using MS ActiveX Data Objects 2.0 Library or do I
need to use a a newer version. Also what is the syntax? I have tried
adorecordset.mo venext or .movefirst but get a parameter error.
If anyone has a solution or even a code snippet I would be extremely
grateful.
Cheers,
Dave.
Dim adoConnection As ADODB.Connectio n
Dim adoRecordset As ADODB.Recordset
Dim connectString As String
CommonDialog1.S howOpen
If CommonDialog1.F ileName <> "" Then
Set adoConnection = New ADODB.Connectio n
Set adoRecordset = New ADODB.Recordset
Let connectString = "Provider=micro soft.jet.oledb. 3.51;" & _
"Data Source=" & CommonDialog1.F ileName
End If
Debug.Print connectString
adoConnection.O pen connectString
'adoRecordset.O pen "Publishers ", adoConnection
adoRecordset.Op en "Publishers ", adoConnection
Do Until adoRecordset.EO F
List1.AddItem adoRecordset!Na me
adoRecordset.Mo veNext
Loop
adoRecordset.Cl ose
adoConnection.C lose
Set adoRecordset = Nothing
Set adoConnection = Nothing
How can I use ADODB to return all tables in an access DB chosen by the
user?
I'm able so far to select the DB file and build up my connect string,
but I would like to offer a list of tables withing the DB and allow
the user to choose.
Is this possible using MS ActiveX Data Objects 2.0 Library or do I
need to use a a newer version. Also what is the syntax? I have tried
adorecordset.mo venext or .movefirst but get a parameter error.
If anyone has a solution or even a code snippet I would be extremely
grateful.
Cheers,
Dave.
Dim adoConnection As ADODB.Connectio n
Dim adoRecordset As ADODB.Recordset
Dim connectString As String
CommonDialog1.S howOpen
If CommonDialog1.F ileName <> "" Then
Set adoConnection = New ADODB.Connectio n
Set adoRecordset = New ADODB.Recordset
Let connectString = "Provider=micro soft.jet.oledb. 3.51;" & _
"Data Source=" & CommonDialog1.F ileName
End If
Debug.Print connectString
adoConnection.O pen connectString
'adoRecordset.O pen "Publishers ", adoConnection
adoRecordset.Op en "Publishers ", adoConnection
Do Until adoRecordset.EO F
List1.AddItem adoRecordset!Na me
adoRecordset.Mo veNext
Loop
adoRecordset.Cl ose
adoConnection.C lose
Set adoRecordset = Nothing
Set adoConnection = Nothing
Comment