Dear All,
The red ellipse line causes an error "Datatable already belongs to this DataSet." How to fix it?
Dear All,
The red ellipse line causes an error "Datatable already belongs to this DataSet." How to fix it?
You will need to make a copy of that table via DataTable.Copy. Once done, use the copy.
How to make a copy? I tried the following syntax. However, "Copy" is redlined. Please help!
Here is how to use Copy
DataSet ds = new DataSet();
DataView dv = new DataView();
dv = ds.Tables["StudentList_Table"].DefaultView;
DataTable dataTable = dv.Table;
DataTable copyTable = dataTable.Copy();
ds.Clear();
var count = copyTable.Rows.Count;
Console.WriteLine(count);
Dear @karenpayneoregon
After copying your code, the redline disappears. However, after pressing the down arrow, the following error still appears.
A DataTable named 'StudentList_table' already belongs to this DataSet.
8 people are following this question.