Trouble removing deleted rows...
-
I have a DataSet that is filled by a SqlDataAdapter. If a row is deleted within the app, this is properly reflected in both the DataSet and central database when Update() is called on the SqlDataAdapter. However, if records are deleted from the database by some other process (outside the application), and I subsequently call the Fill(dataset.table) method of the SqlDataAdapter, the rows that were deleted from the database still seem to exist in the DataSet. Any ideas how I can ensure that if records have been deleted from the database, that these deletions are fully reflected in the DataSet? -- James --
-
I have a DataSet that is filled by a SqlDataAdapter. If a row is deleted within the app, this is properly reflected in both the DataSet and central database when Update() is called on the SqlDataAdapter. However, if records are deleted from the database by some other process (outside the application), and I subsequently call the Fill(dataset.table) method of the SqlDataAdapter, the rows that were deleted from the database still seem to exist in the DataSet. Any ideas how I can ensure that if records have been deleted from the database, that these deletions are fully reflected in the DataSet? -- James --
The deleted rows are likely only visible in the deleted rows view (Datatable retains all your original rows unless you clear it first, or call datatable.acceptchanges after you call Fill to "refresh" the data. Same applies to modifications made by others. Strange behavior perhaps, but that how it's documented. Genius may have its limitations, but stupidity is not thus handicapped. - Elbert Hubbard
-
The deleted rows are likely only visible in the deleted rows view (Datatable retains all your original rows unless you clear it first, or call datatable.acceptchanges after you call Fill to "refresh" the data. Same applies to modifications made by others. Strange behavior perhaps, but that how it's documented. Genius may have its limitations, but stupidity is not thus handicapped. - Elbert Hubbard
Calling AcceptChanges on the datatable after the Fill did not seem to remove the extra records. However, calling Clear on the table just before calling Fill does the trick. I was a little wary of using Clear for fear of deleting my database, but I see it only clears the table and doesn't mark records for deletion. Thanks for the help! -- James --