Results 1 to 4 of 4

Thread: Marking a row for deletion in a dataset.

  1. #1

    Thread Starter
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530

    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?

  2. #2

    Thread Starter
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    You have just run over a speedbump.

  3. #3

    Thread Starter
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    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)

  4. #4
    Lively Member
    Join Date
    Jan 2002
    Posts
    101

    Thumbs up 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
  •  



Click Here to Expand Forum to Full Width