datagrid not showing source RRS feed

  • Question

  • Pretty new at visual basic and actually advance programming in general. I am trying to make a button open up a connection to a MS Access database and fill a datagrid with information from a table called "stock". I have this code linked to a button click: DBSave is a text box and ListView1 is a datagrid.

    Dim DBPath As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBSave.Text

    Dim DBConnect As New OleDb.OleDbConnection()

    DBConnect.ConnectionString = DBPath


    Dim DBAdap As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("SELECT * from Stock", DBConnect)

    Dim DBset As DataSet = New DataSet("Stock")


    ListView1.DataSource = DBset

    After I press the button, nothing shows up in the datagrid and no error messages pop up. Is there something wrong with the database or the code?

    Sunday, February 18, 2007 12:40 AM


  • nevermind. I figured it out. Datasets are sets of tables. I needed to set the datagrid source to DBset.Tables("stock").
    Sunday, February 18, 2007 1:30 AM