Wednesday, September 22, 2010

VB 6.0 Show All Table Names in ComboBox

Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
mdbpassword = "9990513523"
file2 = "account.mdb"

con.Open "Provider=MSDataShape.1;Data Provider = Microsoft.Jet.OLEDB.3.51;Jet OLEDB:Database Password=" & mdbpassword & ";data source=" & file2

Set rs = con.OpenSchema(adSchemaTables)

While Not rs.EOF
If rs("TABLE_TYPE") = ("TABLE") Then
Combo1.AddItem rs!TABLE_NAME

End If
rs.MoveNext
Wend

No comments: