protected void DataGrid1_UpdateCommand(object source, DataGridCommandEventArgs e) { //OleDbConnection con; //OleDbCommand cmd; try { OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=d:\\tanu\\database_hardware.mdb;"); OleDbCommand cmd = new OleDbCommand(); cmd.CommandText = "UPDATE additem SET name=@name, Item_qty=@Item_qty where Item_id=@Item_id"; cmd.Parameters.Add("@name", OleDbType.VarChar).Value = ((TextBox)e.Item.Cells[1].Controls[0]).Text; cmd.Parameters.Add("@Item_qty", OleDbType.Numeric).Value = ((TextBox)e.Item.Cells[2].Controls[0]).Text; cmd.Parameters.Add("@Item_id", OleDbType.Numeric).Value = DataGrid1.DataKeys[e.Item.ItemIndex]; cmd.Connection = con; cmd.Connection.Open(); cmd.ExecuteNonQuery(); cmd.Connection.Close(); DataGrid1.EditItemIndex = -1; Binddata(); } catch (Exception ex) { Response.Write(ex.Message); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)