Click here to Skip to main content
14,333,655 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all visitors
i have 1 table(salesdetail) in sql server 2008
in this table, i have 3 fields(code,itemcode,qty)
in vb.net, i create one form and drop DataGridView on that form
i also set 5 columns on DataGridView(Itemcode,IteamName,Qty,price,Total)
i user sql statement like this ("select itemcode,itemanem,price from item where itemcode=' & txtitemcode.text & "'"")
i use this query to display the item information to my gridview.
when i input 3 items on gridview, i want to save all item in gridView to my table(salesorder)
Note
i want to save only code,itemcode,qty to my salesdetail, for itemname,price,total use for display only.

Please help me how i can save data from gridView to my table?

Best Regards,
TONY
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You can use SqlDataAdapter[^] to reflect changes in the datagridview (or actually in the datatable) to the database.

For example see: http://msdn.microsoft.com/en-us/library/fbk67b6z.aspx[^]

Another note: Don't concatenate literals in your SQL statements ("select itemcode,itemanem,price from item where itemcode=' & txtitemcode.text & "'""). Instead use parameters. More info: SqlParameter [^]
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100