how to empty a dataset/dataadapter

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
 
C

Cor Ligthert[MVP]

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
 

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