hi,
how can i get the column names of an access tables using vb ?
sudha
Printable View
hi,
how can i get the column names of an access tables using vb ?
sudha
DAO or ADO?
ADO
Add a TreeView control (Microsoft Windows Comon Controls) and a Command Button:
VB Code:
Private Sub Command1_Click() Dim cn As ADODB.Connection Dim rsTables As ADODB.Recordset Dim rsFields As ADODB.Recordset Dim strCnn As String Dim nodParent As Node Dim strNewTable As String Dim strCurrentTable As String Set cn = New ADODB.Connection strCnn = "Provider=microsoft.jet.oledb.4.0;Data Source=C:\NWIND.mdb" cn.Open strCnn Set rsFields = cn.OpenSchema(adSchemaColumns) With TreeView1 .LineStyle = tvwRootLines .Indentation = 250 .Nodes.Add , , "root", "Northwind" .Nodes.Add "root", tvwChild, "tables", "Tables" Do Until rsFields.EOF strCurrentTable = rsFields!TABLE_NAME If strCurrentTable <> strNewTable Then strNewTable = strCurrentTable Set nodParent = .Nodes.Add("tables", tvwChild, strCurrentTable, strCurrentTable) End If .Nodes.Add strCurrentTable, tvwChild, , rsFields!COLUMN_NAME rsFields.MoveNext Loop End With rsFields.Close cn.Close End Sub