winforms - Update newly added rows of datagridview to oledb database using c# -


i have datagridview , add , save button. each time add row datagridview add button , @ end save rows database save button.

i want add/few few rows again same datagriview , save database but while saving new items database takes whole datagridview rows again , saves database.

i wanted save new added data or edited data. there way set focus newly added rows or edited rows ? , @ end saves newly added or edited rows?

my datagridview adds/inserts data database @ end.

i using below code saving datagridvew rows database :

                    int chkloop;                      chkloop = dgvorderlist.rows.count;                      messagebox.show(chkloop.tostring());                     foreach (datagridviewrow row in dgvorderlist.rows)                     {                         //messagebox.show(chkloop.tostring());                         //messagebox.show(row.co.tostring());                         if (chkloop != 1)                         {                             comm = new oledbcommand("insert orders_description (itemcode, quantity, amount, orderid, createdon) values ('" + convert.toint32(row.cells["code"].value) + "', '" + convert.toint32(row.cells["quantity"].value) + "', '" + convert.toint32(row.cells["amount"].value) + "', '" + convert.toint32(txtorderno.text) + "', '" + datetime.now + "')", conn);                             messagebox.show(comm.commandtext);                              comm.executenonquery();                             chkloop = chkloop - 1;                          }                     } 

i'm lazy think....... can add additional column checkbox , whenever add new row default value checkbox become selected , when saving check of specific checkbox checked or not. if not checked means it's not new row continue next iteration.

if didn't got said comment below give example.


Comments