title: vb.net listbox display tables names from database
body: <p>I need to list all the tables in the list box from the <code>database.mdb</code> file. Not the contents of the tables just the tables name using <code>Microsoft.Jet.OLEDB.4.0</code></p>
  
  <p>I'm new to vb.net, please help.</p>
  
  <p>this is what i have so far.. and i keep getting errors</p>
  
  <hr>
  
  <pre><code>    Dim dbpath As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)
      dbpath = New Uri(dbpath).LocalPath
      TextBox1.Text = dbpath + "\database.mdb"
  
      Dim userTables As DataTable = Nothing
      Dim connection As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection()
      connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; data source =" textbox1.text
      ' We only want user tables, not system tables
      Dim restrictions() As String = New String(4) {}
      restrictions(3) = "Table"
      connection.Open()
      ' Get list of user tables
      userTables = connection.GetSchema("Tables", restrictions)
      connection.Close()
      ' Add list of table names to listBox
      Dim i As Integer
      For i = 0 To userTables.Rows.Count - 1 Step i + 1
          ListBox1.Items.Add(userTables.Rows(i)(2).ToString())
      Next
  </code></pre>