|
-
Oct 24th, 2002, 02:20 AM
#1
Thread Starter
Registered User
Marking a row for deletion in a dataset.
I am trying to remove one or many rows from a dataset and be able to access the details of each deleted row.
For example:
Dim dr As DataRow
dr =myDataset.Tables("tbl_Alerts").rows(.Rows.Count - 1)
Debug.WriteLine(dr.Item(0) & "," & dr.RowState)
.Rows.Remove(dr)
'dr.Delete()
Debug.WriteLine(dr.Item(0) & "," & dr.RowState)
However I get an exception with the last line:
An unhandled exception of type 'System.Data.RowNotInTableException' occurred in system.data.dll
Although I could store an array of the ids of the rows I have deleted, I would prefer to be able to work with the dataset if possible. Does anyone know how to flag the datarow for deletion without actually deleting it?
-
Oct 24th, 2002, 06:44 PM
#2
Thread Starter
Registered User
You have just run over a speedbump.
-
Oct 24th, 2002, 08:03 PM
#3
Thread Starter
Registered User
found out for anyone that is interested...
If you use the remove method on the rows object like this
datatable("table").Rows.Remove(index)
then the data is purged from the dataset and access to the original data is not possible
If you use the delete method of a datarow, it doesn't remove the data from the data it flags it for deletion until you call accept changes. The only complicating factor is that you cannot access the data in the usual way, you must use this syntax:
datarow.Item(0, DataRowVersion.Original)
-
Mar 20th, 2004, 09:50 AM
#4
Lively Member
It save my life
Good day.
I been scracthing my head whole night in finding a way to access the data of a datarow marked as deleted.
Your thread helps me in solving that.
Thanks.
SonicWave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|