DataTable.Rows.Remove not working

T

trialproduct2004

Hi all

I am having application where i am filling datatable with one table of
my database.

After retrieving all records of table into datatable i want to delete
some records depending on particular condition.

So i used remove method as this is only method i found which is
accepting row to be deleted instead of index.

But after using remove method to delete rows, problem is coming at a
time of saving changes into database using dataadapter.

I used adapter.GetChanges(Rowstate.Deleted) to get information about
those rows which are deleted using 'remove' method. But every time time
this method is returning nothing and not list of deleted rows.

Can someone tell me why this is happening.

If someone knows any other alternative of deleting records without
using index, then please tell me.

Any help will be truely appreciated.

Thanks in advance.
 
G

Guest

trialproduct2004,

Remove completely removes the row from the datatable. So there is nothing
there to indicate to the dataadapter that the row needs to be deleted from
the database.

Instead of Remove you need to use the DataRow's Delete method.

Kerry Moorman
 
T

trialproduct2004

Hi

thanks for your reply.

But delete require index of row to be deleted. And i don't want to
delete row according to index . I want to delete particular row by
passing that row to datacollection.

So can i do this using delete. Or can i delete row by setting condition
on it.

Thanks.
 

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