Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all,

I'm stuck with this problem:

I am loading data from my stock table into a datagridview
and also then saves the data into antoher table(Sales Table).

Thats working good, but where my problem comes in is, I also have a remove button on my Datagridview that is supose to remove the data. It remove it from the datagridview nicely, but from my sales table to remove it there is the problem.

I was thinking on maybe when it save to the sales table it must
send back the Pk_ID of that table.

But How??

Please any help or ideas would be appriciated!!!
Posted

You probably bind the gridview with a datatable.

When you are binding it to Datagridview, you can check DataTable.IsPrimaryKey property to identity which one column is primary key and when delete record you can use that primary key.

Here is the link for how to use:
http://msdn.microsoft.com/en-us/library/system.data.datatable.primarykey.aspx[^]
 
Share this answer
 
You need to use a query like
Delete from sales where SalesId = value
SalesId would be your primary key.
 
Share this answer
 
Comments
Corporal Agarn 26-Aug-11 10:12am    
I do not know who gave you a 2 but with the information provided I thought your answer seems reasonable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900