salamo 3alaykoum
i'm a biginner of C# and i want to execute a button Update, that it suceptible to update any Line Of DataGridView, but when i put the button some errors is showed
as ==> int a = Convert.ToInt32(selectedRow.Cells[0].Value);
please if anyone had a solution text me
private void button3_Click(object sender, EventArgs e){
int selectedrowindex = admuserDataGridView.SelectedCells[0].RowIndex;
DataGridViewRow selectedRow = admuserDataGridView.Rows[selectedrowindex];
int a = Convert.ToInt32(selectedRow.Cells[0].Value);
try{cmd.Connection = cnx;
cmd.CommandType = CommandType.Text;
cnx.Open();
cmd.CommandText = "update admuser set Designation = '" + textdes.Text + "', Quantity = '" + txtQ.Text + "', PR = '" + textpr.Text + "', PO ='" + textpo.Text + "',Main Asset = '" + textMain.Text + "',Sec Asset = '" + textSec.Text + "',Serial Number = '" + textsn.Text + "',Process = '" + textp.Text + "',Supplier = '" + textSp.Text + "',Status = '" + textSt.Text + "',Original Project = '" + textorp.Text + "',Current Project = '" + textcup.Text + "', purchasing date = '" + timer.Value.Date.ToString() + "', Price = '" + textprice.Text + "',Dep Period = '" + textDep.Text + "',NBV = '" + textNBV.Text + "',State = '" + textState.Text + "' where Item=" + a ;
cmd.ExecuteNonQuery();
cnx.Close();
MessageBox.Show("U :D ", "PS");
this.Close();
Administrator ad = new Administrator();
ad.Show();}
catch(Exception ex){MessageBox.Show(ex.ToString()); } } }
What I have tried:
i'm a biginner of C# and i want to execute a button Update, that it suceptible to update any Line Of DataGridView