471,328 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,328 software developers and data experts.

VB.Net Datagrid Reset

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.

Jul 21 '05 #1
1 2224
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.

"Schlauberger" wrote:
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.

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Job Lot | last post: by
5 posts views Thread by Mojtaba Faridzad | last post: by
1 post views Thread by ppn | last post: by
5 posts views Thread by John Richardson | last post: by
1 post views Thread by Vaclav Jedlicka | last post: by
1 post views Thread by Harry Devine | last post: by
1 post views Thread by Lee Price | last post: by
1 post views Thread by Schlauberger | last post: by
9 posts views Thread by rn5a | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.