Hello !
I'm trying to edit and update and cancel in datagrid. Edit and cancel commands are working properly but at UPDATE i m getting this error.(Incorrect syntax near '12').
Please help me. my code is here..
protected void DataGrid1_UpdateCommand(object source, DataGridCommandEventArgs e)
{
num = Convert.ToInt16(e.Item.Cells[1].Text.ToString());
TextBox t1, t2, t3,t4,t5,t6;
t1 = (TextBox)e.Item.Cells[1].Controls[0];
t2 = (TextBox)e.Item.Cells[2].Controls[0];
t3 = (TextBox)e.Item.Cells[3].Controls[0];
t4 = (TextBox)e.Item.Cells[4].Controls[0];
t5 = (TextBox)e.Item.Cells[5].Controls[0];
t6 = (TextBox)e.Item.Cells[6].Controls[0];
cmd = new SqlCommand(" update History set [History ID]=" + t1.Text + ", [User ID]=" + t2.Text + ", [Project ID]= " + t3.Text + ", [Project Start Date]=" + t4.Text + ",[Task Name]=" + t5.Text + ",[Completion Date]=" + t6.Text + " where [History ID]="+num, con);
con.Open();
cmd.ExecuteNonQuery();
adpt = new SqlDataAdapter(cmd);
adpt.Fill(ds);
DataGrid1.EditItemIndex = -1;
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
}
Error is at
cmd.ExecuteNonQuery();
please i m waiting .