Last post Aug 18, 2011 11:16 PM by Decker Dong - MSFT
Aug 17, 2011 09:38 AM|mikediazpr|LINK
Hello. I need help with dataset and datatable. I’m new with asp.net. I use visual studio 2010.
I have a dataset with some datatables and the datatables have some queries. The datatables are the same as the ones in sql server (have all fields). I make a change in the structure of the sql server table (added one field as unique). How do I update the
datatable in the dataset without deleting the old one and adding the updated one? There is like 10 queries on each table and it’s tedious to write all of them with any change of the sql table.
Aug 18, 2011 11:16 PM|Decker Dong - MSFT|LINK
How do I update the datatable in the dataset without deleting the old one and adding the updated one?
As far as I see, it's hard or nearly impossible to update an exsiting DataTable's structures because you have to do quite a lot of things (such as datacolumns' mappings....)
So you can use DataSet.Tables.Clear() and use SqlDataAdapter.Fill a new DataTable and add the table instance into DataSet's Table collection.