VB.Net Datagrid Reset

G

Guest

I have a form that has a Datagrid, there is a menu option that I use to
toggle the Datagrid between two different data sources (x and y). As I
continue to toggle the datagrid is duplication each data set x + x .. and y +
y ...

Is there a way to reset the datagrid?

Current config:

Private ds As DataSet = New DataSet
Private da As OleDb.OleDb.DataAdapter
Private conn as OleDb.OleDb.Connection
Private member as string
Private bolReset as boolean

Private Sub mnuViewSwitch_Click(....)

If bolReset = True then
bolReset = False
Else
bolReset = True
End if

bolError = Load_Grid(bolReset)

End Sub

Private Function Load_Grid(bolDefault as boolean)as boolean

if bolDefault = True then
strSQL = "SELECT ..."

da = New OleDb.OleDbDataAdapter(strSQL,conn)

member = "tblName"

da.Fill(ds, member)

objDataGrid.DataSource = ds.DefaultViewManager
objDataGrid.SetBindings(ds, member)

Else
'code is repeated for different strSQL

Any assistance would be greatly appreciated, Thanks.
 
G

Guest

The simple solutions are always right before our noses:

ds.Clear()

inserted prior to filling the DataAdapter (da) will prevent new data from
being duplicated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top