how to empty a dataset/dataadapter

  • Thread starter Thread starter Aussie Rules
  • Start date Start date
A

Aussie Rules

Hi,

I populate a dataset and then bind a grid to the dataset. The application
allows the user
to repopulate the dataset to show different data in the application.

The problem seems to be that the dataset, keeps the old dataset, as the grid
then displayes multiple datasets, even though I am using the new keyword

Is there a way to totally destroy the contents of the dataset each time I
repopulate it?

My code is :


Dim command2 As New OleDbCommand("select * from WorkSheet_CostDetail
where sheet=" & intWorkSheet, dbConnection)

Dim ds As New DataSet
Dim da2 As New OleDbDataAdapter(command2)

da2.Fill(ds, "ProjectCosts")

FpSpread1.DataSource = ds
 
Aussie

As you create a new dataset, you have to set it again as datasource to the
control.
The old dataset stays as long as there is a reference to it from that
DataGrid.

If you don't use the new dataset, then you can clear the dataset. Simple
enough YourDataset.Clear

Cor
 
Back
Top