Home All Groups Group Topic Archive Search About

Deleted row in dataset??

Author
1 Jun 2006 8:07 AM
Joris De Groote
Hi,

(my code is @ the bottom of this message)

I have a piece of code that runs the rows of a dataset until  it finds the
one needed. When he finds it, I delete that row and start all over again
with the next row I'm looking for, however. I then get this error:
System.Data.DeletedRowInaccessibleException: Deleted row information cannot
be accessed through the row.

The problem seems to be that the dataset deletes the information of the row,
but still keeps the row in it? Now I want to get rid of that one row so my
next run could potentionaly go faster since it has to go over one record
less each time this runs (when the record is below the one that is deleted
offcourse).

Thanks
Joris


While (vi < ds.Tables("vrachtbrieven").Rows.Count)
If (Not
(ds.Tables("docs").Rows(di).Item(0).ToString.Equals(ds.Tables("vrachtbrieven").Rows(vi).Item(0).ToString)))
Then
erin = False
Else
erin = True
ds.Tables("vrachtbrieven").Rows(vi).Delete()
vi = ds.Tables("vrachtbrieven").Rows.Count
End If
vi += 1
End While

Author
1 Jun 2006 8:51 AM
Cor Ligthert [MVP]
Joris,

Deleting of rows is slow, as well be aware that there is a difference
between deleting and removing.
Deleting keeps in some situations the row to make updates to a database
possible
Removing removes the row totally and therefore update is impossible.

But for deleting or removing you can better do a job bottom up with a for
loop

\\\Typed in this message so see it as a kind of pseudo code
For each dr in ds.tables("vrachtbrieven").rows
        For i as integer = ds.Tables("docs").Rows.count - 1 to 0 step -1
                if
(ds.Tables("docs").Rows(i).Item(0).ToString.Equals(ds.Tables("vrachtbrieven").Rows(i).Item
(0).ToString))) then  ds.Tables("docs")Rows(i).Delete
Next
Next
///

I hope this helps,

Cor

Show quoteHide quote
"Joris De Groote" <joris.degro***@skynet.be> schreef in bericht
news:e04d9JVhGHA.4896@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> (my code is @ the bottom of this message)
>
> I have a piece of code that runs the rows of a dataset until  it finds the
> one needed. When he finds it, I delete that row and start all over again
> with the next row I'm looking for, however. I then get this error:
> System.Data.DeletedRowInaccessibleException: Deleted row information
> cannot be accessed through the row.
>
> The problem seems to be that the dataset deletes the information of the
> row, but still keeps the row in it? Now I want to get rid of that one row
> so my next run could potentionaly go faster since it has to go over one
> record less each time this runs (when the record is below the one that is
> deleted offcourse).
>
> Thanks
> Joris
>
>
> While (vi < ds.Tables("vrachtbrieven").Rows.Count)
> If (Not
> (ds.Tables("docs").Rows(di).Item(0).ToString.Equals(ds.Tables("vrachtbrieven").Rows(vi).Item(0).ToString)))
> Then
> erin = False
> Else
> erin = True
> ds.Tables("vrachtbrieven").Rows(vi).Delete()
> vi = ds.Tables("vrachtbrieven").Rows.Count
> End If
> vi += 1
> End While
>
Author
1 Jun 2006 9:10 AM
Joris De Groote
Hi Cor,
thanks for you reply. The situation is that I have 2 tables, one in a
dataset that I go through and another in a dataset wich I go trough every
record of the first table (or until the matching record has been found). Now
this takes quite some time and everyday table 1 gets 2000-3000 extra records
and table 2 1000 extra records, so every day it gets slower. Now I'm looking
for some ways to speed this up and I was thinking that with deleting a
record I could speed it up a bit but since I get this error, it's not that
great sollution it seems.
Could you mayby give some other sollutions on how to speed things up? Would
a select from sql database be faster?

Thanks
Joris


Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:OzxTMhVhGHA.5096@TK2MSFTNGP02.phx.gbl...
> Joris,
>
> Deleting of rows is slow, as well be aware that there is a difference
> between deleting and removing.
> Deleting keeps in some situations the row to make updates to a database
> possible
> Removing removes the row totally and therefore update is impossible.
>
> But for deleting or removing you can better do a job bottom up with a for
> loop
>
> \\\Typed in this message so see it as a kind of pseudo code
> For each dr in ds.tables("vrachtbrieven").rows
>        For i as integer = ds.Tables("docs").Rows.count - 1 to 0 step -1
>                if
> (ds.Tables("docs").Rows(i).Item(0).ToString.Equals(ds.Tables("vrachtbrieven").Rows(i).Item
> (0).ToString))) then  ds.Tables("docs")Rows(i).Delete
> Next
> Next
> ///
>
> I hope this helps,
>
> Cor
>
> "Joris De Groote" <joris.degro***@skynet.be> schreef in bericht
> news:e04d9JVhGHA.4896@TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> (my code is @ the bottom of this message)
>>
>> I have a piece of code that runs the rows of a dataset until  it finds
>> the one needed. When he finds it, I delete that row and start all over
>> again with the next row I'm looking for, however. I then get this error:
>> System.Data.DeletedRowInaccessibleException: Deleted row information
>> cannot be accessed through the row.
>>
>> The problem seems to be that the dataset deletes the information of the
>> row, but still keeps the row in it? Now I want to get rid of that one row
>> so my next run could potentionaly go faster since it has to go over one
>> record less each time this runs (when the record is below the one that is
>> deleted offcourse).
>>
>> Thanks
>> Joris
>>
>>
>> While (vi < ds.Tables("vrachtbrieven").Rows.Count)
>> If (Not
>> (ds.Tables("docs").Rows(di).Item(0).ToString.Equals(ds.Tables("vrachtbrieven").Rows(vi).Item(0).ToString)))
>> Then
>> erin = False
>> Else
>> erin = True
>> ds.Tables("vrachtbrieven").Rows(vi).Delete()
>> vi = ds.Tables("vrachtbrieven").Rows.Count
>> End If
>> vi += 1
>> End While
>>
>
>
Author
1 Jun 2006 9:22 AM
Cor Ligthert [MVP]
Joris,

Did you try my sample?

(The inner for loop can be exited of course with an Exit For and than the
then becomes an then with an end if.)

I assume that in fact every day this has to be done completely, althoug as I
understand you well, than you can use in the outerloop use instead of the
complete table only the additions for this day, which you probably can get
with a where clause.

Cor

Show quoteHide quote
"Joris De Groote" <joris.degro***@skynet.be> schreef in bericht
news:uboANtVhGHA.1276@TK2MSFTNGP03.phx.gbl...
> Hi Cor,
> thanks for you reply. The situation is that I have 2 tables, one in a
> dataset that I go through and another in a dataset wich I go trough every
> record of the first table (or until the matching record has been found).
> Now this takes quite some time and everyday table 1 gets 2000-3000 extra
> records and table 2 1000 extra records, so every day it gets slower. Now
> I'm looking for some ways to speed this up and I was thinking that with
> deleting a record I could speed it up a bit but since I get this error,
> it's not that great sollution it seems.
> Could you mayby give some other sollutions on how to speed things up?
> Would a select from sql database be faster?
>
> Thanks
> Joris
>
>
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
> news:OzxTMhVhGHA.5096@TK2MSFTNGP02.phx.gbl...
>> Joris,
>>
>> Deleting of rows is slow, as well be aware that there is a difference
>> between deleting and removing.
>> Deleting keeps in some situations the row to make updates to a database
>> possible
>> Removing removes the row totally and therefore update is impossible.
>>
>> But for deleting or removing you can better do a job bottom up with a for
>> loop
>>
>> \\\Typed in this message so see it as a kind of pseudo code
>> For each dr in ds.tables("vrachtbrieven").rows
>>        For i as integer = ds.Tables("docs").Rows.count - 1 to 0 step -1
>>                if
>> (ds.Tables("docs").Rows(i).Item(0).ToString.Equals(ds.Tables("vrachtbrieven").Rows(i).Item
>> (0).ToString))) then  ds.Tables("docs")Rows(i).Delete
>> Next
>> Next
>> ///
>>
>> I hope this helps,
>>
>> Cor
>>
>> "Joris De Groote" <joris.degro***@skynet.be> schreef in bericht
>> news:e04d9JVhGHA.4896@TK2MSFTNGP05.phx.gbl...
>>> Hi,
>>>
>>> (my code is @ the bottom of this message)
>>>
>>> I have a piece of code that runs the rows of a dataset until  it finds
>>> the one needed. When he finds it, I delete that row and start all over
>>> again with the next row I'm looking for, however. I then get this error:
>>> System.Data.DeletedRowInaccessibleException: Deleted row information
>>> cannot be accessed through the row.
>>>
>>> The problem seems to be that the dataset deletes the information of the
>>> row, but still keeps the row in it? Now I want to get rid of that one
>>> row so my next run could potentionaly go faster since it has to go over
>>> one record less each time this runs (when the record is below the one
>>> that is deleted offcourse).
>>>
>>> Thanks
>>> Joris
>>>
>>>
>>> While (vi < ds.Tables("vrachtbrieven").Rows.Count)
>>> If (Not
>>> (ds.Tables("docs").Rows(di).Item(0).ToString.Equals(ds.Tables("vrachtbrieven").Rows(vi).Item(0).ToString)))
>>> Then
>>> erin = False
>>> Else
>>> erin = True
>>> ds.Tables("vrachtbrieven").Rows(vi).Delete()
>>> vi = ds.Tables("vrachtbrieven").Rows.Count
>>> End If
>>> vi += 1
>>> End While
>>>
>>
>>
>
>
Author
1 Jun 2006 3:08 PM
Joris De Groote
Hi,

Thanks for your response. I have used your advice with the where clause and
this could help me quite a bit :). Why didn't I come up with this...

Joris

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%23kc4YyVhGHA.3496@TK2MSFTNGP04.phx.gbl...
> Joris,
>
> Did you try my sample?
>
> (The inner for loop can be exited of course with an Exit For and than the
> then becomes an then with an end if.)
>
> I assume that in fact every day this has to be done completely, althoug as
> I understand you well, than you can use in the outerloop use instead of
> the complete table only the additions for this day, which you probably can
> get with a where clause.
>
> Cor
>
> "Joris De Groote" <joris.degro***@skynet.be> schreef in bericht
> news:uboANtVhGHA.1276@TK2MSFTNGP03.phx.gbl...
>> Hi Cor,
>> thanks for you reply. The situation is that I have 2 tables, one in a
>> dataset that I go through and another in a dataset wich I go trough every
>> record of the first table (or until the matching record has been found).
>> Now this takes quite some time and everyday table 1 gets 2000-3000 extra
>> records and table 2 1000 extra records, so every day it gets slower. Now
>> I'm looking for some ways to speed this up and I was thinking that with
>> deleting a record I could speed it up a bit but since I get this error,
>> it's not that great sollution it seems.
>> Could you mayby give some other sollutions on how to speed things up?
>> Would a select from sql database be faster?
>>
>> Thanks
>> Joris
>>
>>
>> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
>> news:OzxTMhVhGHA.5096@TK2MSFTNGP02.phx.gbl...
>>> Joris,
>>>
>>> Deleting of rows is slow, as well be aware that there is a difference
>>> between deleting and removing.
>>> Deleting keeps in some situations the row to make updates to a database
>>> possible
>>> Removing removes the row totally and therefore update is impossible.
>>>
>>> But for deleting or removing you can better do a job bottom up with a
>>> for loop
>>>
>>> \\\Typed in this message so see it as a kind of pseudo code
>>> For each dr in ds.tables("vrachtbrieven").rows
>>>        For i as integer = ds.Tables("docs").Rows.count - 1 to 0 step -1
>>>                if
>>> (ds.Tables("docs").Rows(i).Item(0).ToString.Equals(ds.Tables("vrachtbrieven").Rows(i).Item
>>> (0).ToString))) then  ds.Tables("docs")Rows(i).Delete
>>> Next
>>> Next
>>> ///
>>>
>>> I hope this helps,
>>>
>>> Cor
>>>
>>> "Joris De Groote" <joris.degro***@skynet.be> schreef in bericht
>>> news:e04d9JVhGHA.4896@TK2MSFTNGP05.phx.gbl...
>>>> Hi,
>>>>
>>>> (my code is @ the bottom of this message)
>>>>
>>>> I have a piece of code that runs the rows of a dataset until  it finds
>>>> the one needed. When he finds it, I delete that row and start all over
>>>> again with the next row I'm looking for, however. I then get this
>>>> error:
>>>> System.Data.DeletedRowInaccessibleException: Deleted row information
>>>> cannot be accessed through the row.
>>>>
>>>> The problem seems to be that the dataset deletes the information of the
>>>> row, but still keeps the row in it? Now I want to get rid of that one
>>>> row so my next run could potentionaly go faster since it has to go over
>>>> one record less each time this runs (when the record is below the one
>>>> that is deleted offcourse).
>>>>
>>>> Thanks
>>>> Joris
>>>>
>>>>
>>>> While (vi < ds.Tables("vrachtbrieven").Rows.Count)
>>>> If (Not
>>>> (ds.Tables("docs").Rows(di).Item(0).ToString.Equals(ds.Tables("vrachtbrieven").Rows(vi).Item(0).ToString)))
>>>> Then
>>>> erin = False
>>>> Else
>>>> erin = True
>>>> ds.Tables("vrachtbrieven").Rows(vi).Delete()
>>>> vi = ds.Tables("vrachtbrieven").Rows.Count
>>>> End If
>>>> vi += 1
>>>> End While
>>>>
>>>
>>>
>>
>>
>
>