The following code is for binding all tables names from SQL server database into listbox. For it we are using query that select all object from sysobjects with an xtype of ‘U’.
The example requires a Listbox control named ListBox1.
Dim sqlConn As New SqlClient.SqlConnection("put your connection string") sqlConn.Open() Dim cmd As New SqlClient.SqlCommand("Select * From sys.objects Where type = 'U' order by name", sqlConn) Dim dsColumns As New DataSet Dim daAdapter As New SqlClient.SqlDataAdapter(cmd) daAdapter.Fill(dsColumns) If dsColumns.Tables(0).Rows.Count > 0 Then ListBox1.Items.Clear() For i As Integer = 0 To dsColumns.Tables(0).Rows.Count - 1 ListBox1.Items.Add(dsColumns.Tables(0).Rows(i)(0).ToString()) Next Else MessageBox.Show("Tables not found.") End If