View tables in open connection
Hello all,
Is there a way that I can vew the tables once I have connected to an open connection?
Code:
' create a connection object
Dim conn As New AdsConnection(MyConnectionString)
'make the connection to the server
conn.Open() 'Once connected I want to see the tables available
Once I know what tables are here I'll know what to select in my subsequent command object.
Thanks,
Strick
Re: View tables in open connection
That will vary from database system to database system. What are you using?
Re: View tables in open connection
^ true...
vb Code:
Dim SchemaTable As DataTable = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, Nothing})
Dim int As Integer
For int = 0 To SchemaTable.Rows.Count - 1
If SchemaTable.Rows(int)!TABLE_TYPE.ToString = "TABLE" Then
'Add items to list box
ListBox1.Items.Add(SchemaTable.Rows(int)!TABLE_NAME.ToString())
End If
Next
That should get you going : ).
Justin