Save DataGrid Edited data to MS Access Database
Posted on 2008-10-28
Visual Studio 2005
I have a DataGrid that has displayed some data to a user. (it reads an XML file)
The User has the ability to edit the individual cells on the datagrid.
Once they are done I want them to be able to click a button and write all the datagrid data to a MS Access database.
Database is called: "OnlineOrders.mdb"
Table is called "Orders"
There are 5 Fields: OrderID, Product, Quantity, Cost, Description
4 of which correspond to the displayed DataGrid colums (Product, Quantity, Cost, Description)
OrderID is stored asa variable by itself.
Each row will need to be inserted into the database
I know what the SQL should be:
"Insert into Orders (OrderID, Product, Quantity, Cost, Description) Values (''+OrderID+', '"+Product+"', '"+Quantity+"', '"+Cost+"', '"+Description+"')"
But I do not know how to setup the database code in VB.net orhow to loop through the rows.
I need help with the data setup and then looping through the datagrid contents.