rebuilding a dataset/datatable

  • Thread starter Thread starter Bernie Yaeger
  • Start date Start date
B

Bernie Yaeger

I use the following code to clear out a dataset (let's suppose the dataset
has been changed but not the back end, by design) after having once called
the .fill method of a data adapter:
dspubpay.Tables(0).Clear()

dspubpay.Tables(0).Dispose()

I then can simply rebuild table(0) with the usual fill method:


dapubpay.Fill(dspubpay, "pubpay")



My question is, is there any problem with doing this; also, is there a
better way of refreshing the dataset with the current data from the back
end?



Thanks for any help.



Bernie Yaeger
 
Bernie:

Clear should empty the existing rows in your datatable so I don't think
calling dispose is necessary. Other than that you look good to go.

HTH,

Bill
 
Clear empties you dataset of the rows and its data, but the table and its
structure will not be erased.

rg,
Eric
 
Hi Bernie,

The documentation says that a fill does after an da.update an update of the
dataset.

Who is better than you with that hugh dataset to see what that means.

da.update(ds)
da.fill(ds)

Works fine, I do only not know what that means for the performance.

Cor
 
Hi Bill,

I was afraid that without .dispose, the fill would create not table (0) but
rather table (1).

Let me know what you think.

Tx,

Bernie
 
Hi Eric,

Will .dispose erase it?

Tx,

Bernie

EMW said:
Clear empties you dataset of the rows and its data, but the table and its
structure will not be erased.

rg,
Eric
 
Hi Cor,

Actually, I've found that a fill after a previous fill will double the data.
That's why I .clear and then .dispose.

Thanks for your help, as always.

Bernie
 
Bernie:

No, it won't unless you specify another table name. Clear will get rid of
all of the rows and you can call fill on the table with either the table
name or the table index. Either way you should be good, but calling dispose
would add some overhead. It's not a big deal in most instances, but if you
had a Grid or some controls bound to the table, then disposed of it, you
might give you some grief.
 
Hi Bernie,

Can you try something as this?

da.update(ds)
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
da.Fill(ds)

Cor
 
Back
Top