Delete records from dataset

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

I have a dataset that I do not want written back to the table. I need to
delete rows from the dataset where to fields are equal...example

Dataset1
bridge <---- pk
amt
rec

if amt =rec , i want to delete / remove the record but cant figure it out

any help will be appreciated

Steve
 
Hi Stephen,

Dim irow as datarow
For each irow in ds1.tables(0).rows
if irow("amt") = irow("rec") then
irow.delete()
end if
Next

HTH,

Bernie Yaeger
 
Bernie... that did the trick....

thank you

Bernie Yaeger said:
Hi Stephen,

Dim irow as datarow
For each irow in ds1.tables(0).rows
if irow("amt") = irow("rec") then
irow.delete()
end if
Next

HTH,

Bernie Yaeger
 
Stephen,

Bernie gave the solution, however there is a big difference in removing a
row and deleting a row.

When you want to remove a row from a dataset that will not be deleted in the
database in the next dataadapter update. Therefore is the instruction
"remove" and you understand it already when you use "delete" it will be
removed from the database in the next update. In that update command, it
will than be removed by the dataadapter when done. (or by the acceptchanges
when you use not the complete dataset in the update and you use that).

A "delete" set the rowstate to delete (when it is not created new in that
session, because than it is removed)
A "remove" removes forever the row so there is no rowstate anymore.

I hope this gives some idea's

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top