dataset reuse

T

tg

i have a strongly typed dataset that i will continually refill with
different data using SQL queries and want to process the data in each.

I get the first dataset fine, using a SQL command object and using a
dataAdapter.Fill() etc, and everything works fine. If i want to refill
that dataset with new data using dataAdapter.Fill() again, it doesn't
work. instead, the old data still remains in the dataset.

i've tried using the Clear() and Reset() methds of the dataset before
calling dataAdapter.Fill() with no avail. Here's some pseudocode to
help explain what i'm trying to do.

JobsDS ds = new JobsDS() // my custom dataset
....
//setup the data adapter, sql connection, command object
....

bool done = false;

while(!done)
{
// jobs is the table i'm always pulling data from.
da.fill(ds, "Jobs");
// process dataset with the new data from the above line

if( done_processing)
done = true;
}
 
C

Chris

tg said:
i have a strongly typed dataset that i will continually refill with
different data using SQL queries and want to process the data in each.

I get the first dataset fine, using a SQL command object and using a
dataAdapter.Fill() etc, and everything works fine. If i want to refill
that dataset with new data using dataAdapter.Fill() again, it doesn't
work. instead, the old data still remains in the dataset.

i've tried using the Clear() and Reset() methds of the dataset before
calling dataAdapter.Fill() with no avail. Here's some pseudocode to
help explain what i'm trying to do.

JobsDS ds = new JobsDS() // my custom dataset
...
//setup the data adapter, sql connection, command object
...

bool done = false;

while(!done)
{
// jobs is the table i'm always pulling data from.
da.fill(ds, "Jobs");
// process dataset with the new data from the above line

if( done_processing)
done = true;
}

Are you sure that the Dataadapter has the new sql query?

Chris
 
T

tg

yes. well, i set the command text to the new value i want it to have.
after the initial setup, i try to do this to "refill" the dataset with
new data:


cmd.CommandText = "SELECT ...."
// i've tried calling dataset.Reset() and dataset.Clear() here
int result = dataAdapter.Fill(dataset, "Jobs")
// result here is zero even when i know the query should return rows

Tyler
 

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