Question Saving Datagridview multiple rows under one Composite key.

nickhunter82

New member
Joined
Apr 4, 2011
Messages
1
Programming Experience
3-5
Hi
i am developing a program to a Computer shop. In my main form there are few textboxes to enter the customer details (EX: INVOICE NO, CUSTOMER NAME ,BILL TO, ETC)and i have separate table named "Customer". And also in the main form there is a datagridview to enter the Products that the customer is buying.(Ex:processor,HDD,RAM,VGA,etc). The columns are in the Datagridview as ITEM CODE,DESCRIPTION,QUANTITY,PRICE,AMOUNT,WARRANTY)

The display of the datagridview will be like this,

ITEM CODE | DESCRIPTION | QUANTITY | PRICE | AMOUNT | WARRANTY
XXXX | XXXXX | XXXXXX | XXXX | XXXXXX | XXXXXXX | XXXXXXX
CCCCC | CCCCCC | CCCCCCCC | CCCC | CCCCC | CCCCCCC | CCCCCCCC

So my problem is that i want to save the products in the datagridview to another table called "Purchase" as keeping the Invoice No as the primary and the user be able to search the transaction via the Invoice No.(Invoice Number is the Primary key of "Customer Table").

Plz help coz i am stucked in this for weeks now and i also tried with "COMPOSITE KEY" But it didnt worked for me.
 
Simply create a DataTable with the appropriate columns and bind it to the grid. When you're done, use a DataAdapter to save the contents of the DataTable to the database.
 
Back
Top