How to delete Table from Dataset ONLY

  • Thread starter Thread starter nashak
  • Start date Start date
N

nashak

I want to check if table exists in the dataset. If it does, then I want
to delete it and create a new table of the same name in the dataset. I
do not want any changes to be made to my datasource. How can I do this?
Thanks
 
Here's how ----

ds.Tables["tablename"] <--- that'll give you the table you are interested
in - if it exists, this'll be non null.
Alternatively, you can use ds.tables.contains

Once you have the necessary table, you can do
ds.Tables.Remove

Then discard the table if you don't care to preserve it,

Then create a new datatable and do ds.tables.add(newdatatable).

Thats it.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
http://blogs.apress.com/authors.php?author=Sahil Malik
 
Back
Top