datatable.reset()

reddzer

Member
Joined
Apr 20, 2007
Messages
6
Programming Experience
Beginner
I populate the datatable with the values of TABLE1 from the database, these are then displayed in the datagridview "grid" i then reset the datatable and repopulate with the values of TABLE2 from the database. i now try to display these new values in the grid but i cannot see the rows, only the column headers (Column1, Column2, Column3 etc)

if i click on one of the column headers the rows then appear. does anyone know how to make these rows appear without having to click the grid


VB.NET:
        Dim queryAdapter As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("SELECT * FROM table1", connection)
        Dim ds As DataSet = New DataSet()
        Dim dt As DataTable = New DataTable()
        Dim datatable2 As DataTable = New DataTable()

        ds.Tables.Add(dt)
        queryAdapter.Fill(dt)
        grid1.DataSource = dt

        MsgBox("")

        queryAdapter = New OleDb.OleDbDataAdapter("SELECT * FROM table2", connection)
        dt.Reset()
        queryAdapter.Fill(dt)
        grid1.DataSource = dt
 
As a .NET 2.0 user you shouldnt really be doing this.. Take a read of the DW2 link in my sig, section on Displaying data in an app (or even the Simple App section)

Fill alternately table 1 or table 2. Set the datasource of the grid to the relevant binding source at that time..
 
Back
Top