andyd70
asked on
Refresh data in a Bound datagridview VB.NET
I have a datagridview in a Windows Forms Vb.NET App. The datagridview is filled in the following manner.
Dim daLines As New SqlDataAdapter("Select L.CIV_LINE_ID, L.CIV_HD_ID, L.LINE_NO, L.PRODUCT_CODE from IMPORTED_CIV_LINES L WHERE L.CIV_HD_ID = '" & grdInvoiceList.CurrentRow. Cells(7).V alue.ToStr ing & "'", dbacotconn)
daLines.Fill(dslines, "LINES")
grdLines.DataSource = dslines
grdLines.DataMember = "LINES"
As I do some cell formatting the dslines is declared as a public var.
The datagridview is filled when the user selects a row in another grid.
What I have found is that the datagridview is not clearing. The results are appending to the results of the last time it was filled. I thought I would then perhaps try to delete the contents of the datagridview and re-fresh/re-read when the DA Filled the DS. I cannot get this to work.
Can anybody provide me an easier way of refreshing data in a datagridview from a Dataset ???
Dim daLines As New SqlDataAdapter("Select L.CIV_LINE_ID, L.CIV_HD_ID, L.LINE_NO, L.PRODUCT_CODE from IMPORTED_CIV_LINES L WHERE L.CIV_HD_ID = '" & grdInvoiceList.CurrentRow.
daLines.Fill(dslines, "LINES")
grdLines.DataSource = dslines
grdLines.DataMember = "LINES"
As I do some cell formatting the dslines is declared as a public var.
The datagridview is filled when the user selects a row in another grid.
What I have found is that the datagridview is not clearing. The results are appending to the results of the last time it was filled. I thought I would then perhaps try to delete the contents of the datagridview and re-fresh/re-read when the DA Filled the DS. I cannot get this to work.
Can anybody provide me an easier way of refreshing data in a datagridview from a Dataset ???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I know that i have tried this before, The Problem was that it failed initially. I put the Table.Clear inside a Try Catch block and all worked.
Thank you for your help
Thank you for your help
if not dslines is nothing then
dslines.dispose
dslines = nothing
endif
dslines = new dataset