for update data in gridview it shows the same value? windows forms?

Posted by Sudheep.grandhe under C# on 1/12/2012 | Points: 10 | Views : 1320 | Status : [Member] | Replies : 0
Hi,

i am trying to update the record on basis of invoiceno.in tbl_report1 i have to update the details .the tbl_report1 columns are invoiceno(FK),particulars,quantity,perprice,amount,invoicedate,ondate,compname.

if i am trying to update the quantity column it will update the remaining records also with same value.for eg:invoiceno-34 i want to update quantity as 3 it will be updated in 35,36....so on records as 3 only.how can i solve this issue.please do the needful.

this is my code for update.


void update(int row)
{
DataGridViewCell cell = dataSimpeGrid.CurrentCell as DataGridViewCell;
if (cell.IsInEditMode)
{
string query;
sqlcon.Open();
query = "update tbl_report1 set quantity='" + dataSimpeGrid.Rows[row].Cells[2].EditedFormattedValue + "', perprice='" + dataSimpeGrid.Rows[row].Cells[3].EditedFormattedValue + "', amount='" + dataSimpeGrid.Rows[row].Cells[4].EditedFormattedValue + "', orderno='" + dataSimpeGrid.Rows[row].Cells[5].EditedFormattedValue + "', invoicedate='" + dataSimpeGrid.Rows[row].Cells[7].EditedFormattedValue + "', ondate='" + dataSimpeGrid.Rows[row].Cells[8].EditedFormattedValue + "'where invoiceno="+invoiceno +"";
sqlcmd = new SqlCommand(query, sqlcon);
sqlcmd.ExecuteNonQuery();
sqlcon.Close();
MessageBox.Show("Record Updated Successfully");
}
}



Best,
Sudheep.

Best,
Sudheep.



Responses

(No response found.)

Login to post response