Delete Row Problem

E

Erica

Hello,

When I delete a row in my dataset, the row state for other rows in the
dataset (other datatables) rowstate is deleted. Why is that? Here is the
code I use to delete the row:

I have tried both methods below and get same result:
dataSet.Table1[0].Delete();
dataSet.Tables.Rows.Remove(dataRow);

Thanks
 
W

William Ryan eMVP

Hi Erica:

in your first statement, you aren't specificing a row. You need to use
DataSet.Tables[TableIndex].Rows[RowIndex].Delete();
or you can use a specific row instead of RowINdex
DataSet.Tables[TableIndex].Rows[dataRow].Delete();


Remember .Remove() != .Delete(); Remove takes it out of the collection so
the adapter will never see it when it does and update b/c it's gone
http://www.knowdotnet.com/articles/efficient_pt4.html
..Delete on the other hand doesn't affect the Rows.Count until you call
Update or AcceptChanges is called (Update calls AcceptChanges)

HTH,

Bill
--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
 

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

Top