473,327 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

how to empty a dataset/dataadapter

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
Mar 14 '08 #1
1 10599
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

"Aussie Rules" <au****@nospam.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
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

Mar 14 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Eva | last post by:
hi, is it possible to create an empty dataset with a schema (i.e table headings and datatypes) the same as one of the tables in my database? Also can i create my own empty dataset with my own...
2
by: Phil Galey | last post by:
How do you get around the problem of empty tables in a dataset not being included when you do a WriteXML? When you later read the data back into a new dataset, those tables are gone, because they...
2
by: Jim | last post by:
In my Win App, I have a datagrid that's bound to a dataset. When the form loads, the datagrid fills. How can I add an empty row to the end of the datagrid during a button click (similar to...
2
by: Mojtaba Faridzad | last post by:
Hi, Please check these lines: DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet, "mytable"); DataRow row; row = dataSet.Tables.Rows; row.BeginEdit(); row = "555";
3
by: JacksonYin | last post by:
1. I can fill data from Excel to DataSet like this: OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../../Book1.xls;Extended Properties=Excel...
15
by: JIM.H. | last post by:
Hello, Can I send a dataset as a parameter into stored procedure and import data to a table in the stored procedure? Thanks, Jim.
22
by: EMW | last post by:
Hi, I managed to create a SQL server database and a table in it. The table is empty and that brings me to my next chalenge: How can I get the info in the table in the dataset to go in an empty...
12
by: chreo | last post by:
I GIVE UP...I can't refresh datagrid (dataset) I have datagrid = dgrPaczki Datasource of that datagrid = DataSetPaczki1.PACZKI_PAKOWALNIA (forgive me Polish words) Dataadapter which fills my...
4
by: Robert Bravery | last post by:
Hi All, I'm New to VS.net. Trying to figure out this new dataset thingy. Ok so I add a dataadapter with all the correct properties for a table. Then generate the dataset. Now open the dataset and...
7
by: David P. Donahue | last post by:
My experience with databases using C# has been pretty limited thus far. Mostly I just use a SELECT statement to populate a DataSet, which is just read-only (mostly for display on a web page), or...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.