I'm adding a datatable to a dataset like this:
DataTable dtImage = new DataTable();
//some updates in the Datatable
ds.Tables.Add(dtImage);
But the next time, when the datatable gets updated, will it be reflected in the dataset? or we need to write some code to make it reflected?
Also, I'm checking the dataset if the datatable exists in the dataset already using:
if(!ds.Tables.Contains("dtImage"))
ds.Tables.Add(dtImage);
In the first iteration, ds.Tables.Contains("dtImage")
is false, so, ds.Tables.Add(dtImage)
adds the table to the dataset. But in the second iteration, ds.Tables.Contains("dtImage")
is false again, but ds.Tables.Add(dtImage)
throws an error:
Datatable already belongs to this dataset.
If the dataset doesn't contain the datatable named "dtImage", why is it throwing an error?
Update: Thanks, that issue got solved. Pls answer this:
But the next time, when the datatable gets updated, will it be reflected in the dataset? or we need to write some code to make it reflected?