By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,905 Members | 902 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,905 IT Pros & Developers. It's quick & easy.

Deleted row in dataset??

P: n/a
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.Equal s(ds.Tables("vrachtbrieven").Rows(vi).Item(0).ToSt ring)))
Then
erin = False
Else
erin = True
ds.Tables("vrachtbrieven").Rows(vi).Delete()
vi = ds.Tables("vrachtbrieven").Rows.Count
End If
vi += 1
End While
Jun 1 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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" <jo************@skynet.be> schreef in bericht
news:e0**************@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.Equal s(ds.Tables("vrachtbrieven").Rows(vi).Item(0).ToSt ring)))
Then
erin = False
Else
erin = True
ds.Tables("vrachtbrieven").Rows(vi).Delete()
vi = ds.Tables("vrachtbrieven").Rows.Count
End If
vi += 1
End While

Jun 1 '06 #2

P: n/a
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]" <no************@planet.nl> wrote in message
news:Oz**************@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" <jo************@skynet.be> schreef in bericht
news:e0**************@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.Equal s(ds.Tables("vrachtbrieven").Rows(vi).Item(0).ToSt ring)))
Then
erin = False
Else
erin = True
ds.Tables("vrachtbrieven").Rows(vi).Delete()
vi = ds.Tables("vrachtbrieven").Rows.Count
End If
vi += 1
End While


Jun 1 '06 #3

P: n/a
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" <jo************@skynet.be> schreef in bericht
news:ub**************@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]" <no************@planet.nl> wrote in message
news:Oz**************@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" <jo************@skynet.be> schreef in bericht
news:e0**************@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.Equal s(ds.Tables("vrachtbrieven").Rows(vi).Item(0).ToSt ring)))
Then
erin = False
Else
erin = True
ds.Tables("vrachtbrieven").Rows(vi).Delete()
vi = ds.Tables("vrachtbrieven").Rows.Count
End If
vi += 1
End While



Jun 1 '06 #4

P: n/a
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

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@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" <jo************@skynet.be> schreef in bericht
news:ub**************@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]" <no************@planet.nl> wrote in message
news:Oz**************@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" <jo************@skynet.be> schreef in bericht
news:e0**************@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.Equal s(ds.Tables("vrachtbrieven").Rows(vi).Item(0).ToSt ring)))
Then
erin = False
Else
erin = True
ds.Tables("vrachtbrieven").Rows(vi).Delete()
vi = ds.Tables("vrachtbrieven").Rows.Count
End If
vi += 1
End While



Jun 1 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.