Re: Deleted row in dataset??
- From: "Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx>
- Date: Thu, 1 Jun 2006 11:22:04 +0200
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.degroote@xxxxxxxxx> schreef in bericht
news:uboANtVhGHA.1276@xxxxxxxxxxxxxxxxxxxxxxx
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]" <notmyfirstname@xxxxxxxxx> wrote in message
news:OzxTMhVhGHA.5096@xxxxxxxxxxxxxxxxxxxxxxx
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.degroote@xxxxxxxxx> schreef in bericht
news:e04d9JVhGHA.4896@xxxxxxxxxxxxxxxxxxxxxxx
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
.
- Follow-Ups:
- Re: Deleted row in dataset??
- From: Joris De Groote
- Re: Deleted row in dataset??
- References:
- Deleted row in dataset??
- From: Joris De Groote
- Re: Deleted row in dataset??
- From: Cor Ligthert [MVP]
- Re: Deleted row in dataset??
- From: Joris De Groote
- Deleted row in dataset??
- Prev by Date: Re: Deleted row in dataset??
- Next by Date: Re: loading frames asp
- Previous by thread: Re: Deleted row in dataset??
- Next by thread: Re: Deleted row in dataset??
- Index(es):
Relevant Pages
|