Question DataGridView disappears data after updating from DB

Budius

Well-known member
Joined
Aug 6, 2010
Messages
137
Location
UK
Programming Experience
3-5
it's quite a simple code to load the data into the datagridview:

VB.NET:
        If Not db.Query("SELECT id as 'ID', name as 'Name' FROM subsidiary", ds.Tables("subsidiary")) Then
            MessageBox.Show(db.ErrorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            btn_Go.Enabled = False
            Return
        End If
        With tbl_subsidiary
            .DataSource = ds.Tables("subsidiary")
            .ReadOnly = True
            .AutoResizeColumns()
            .RowHeadersVisible = False
            .Columns("Name").Width = .Width - .Columns("Id").Width - 5
            For Each col As DataGridViewColumn In .Columns
                col.SortMode = DataGridViewColumnSortMode.NotSortable
            Next
        End With

it works perfect when I call it on form load....
but then after some data changed in the SQL and repeat the routine, the table doesn't show any row. The columns are there, but the rows disappear.

if I allow the col.SortMode for the user to sort... and then click on the columns.. the data appear...
I already tried to put a .Refresh there and nothing changed....


any suggestions???
 
FYI:

I'm still out of luck for this one... for testing purposes I changed to only run this whole Sub on form load
then I'm just changing the datatable (by querying the database) and the numbers on the datagridview still disappears....

ideas ?
 
Back
Top