VB code to show all table names of a databse

Unknown | 8:57 AM |

Dim rs As ADODB.Recordset
Dim con As New ADODB.Connection
Dim tables() As String
Dim table1, tablename As String
Dim i As Integer
Private Sub Command1_Click()
If con.State = adStateOpen Then
con.Close
End If
con.Open "Provider=SQLOLEDB.1;Data Source=.;Initial Catalog=GMS;Integrated Security=SSPI"
Set rs = New ADODB.Recordset
Set rs = con.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "TABLE"))

Do Until rs.EOF
'MsgBox rs!table_name
'Combo1.AddItem (rs!table_name)
If table1 = "" Then
table1 = rs!table_name
Else

table1 = table1 & "," & rs!table_name
End If


rs.MoveNext
Loop
rs.Close
tablename = "adcdata"
Set rs = Nothing
tables() = Split(table1, ",")
For i = 0 To UBound(tables()) - 1

If tablename = tables(i) Then
MsgBox "yes"
Else
End If

Next i

MsgBox table1
End Sub

Private Sub Form_Load()
'con.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & " data source=" & App.Path & "\rubberpark.mdb"
End Sub

Category:

About http://dotnetvisual.blogspot.in/:
DOT NET TO ASP.NET is a web application framework marketed by Microsoft that programmers can use to build dynamic web sites, web applications and web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime, allowing programmers to write ASP.NET code using any Microsoft .NET language. create an application very easily ....