Hi all,
The following is my code:
private void Update_data(Object sender, DataGridCommandEventArgs e)
{
try
{
String updateCmd = "update rohsdb set Supplier=? where PortNo=?";
OleDbConnection myConnection= new OleDbConnection("Provider=MSDAORA; Data Source=***;User ID=system;Password=***");
OleDbCommand myCommand = new OleDbCommand(updateCmd,myConnection);
myCommand.Parameters.Add(new OleDbParameter("@PortNo",OleDbType.VarChar,50));
myCommand.Parameters["@PortNo"].Value= DataGrid1.DataKeys[(int)e.Item.ItemIndex];
myCommand.Parameters.Add(new OleDbParameter("@Supplier",OleDbType.VarChar,50));
myCommand.Parameters["@Supplier"].Value= ((TextBox)e.Item.FindControl("edit_supplier")).Text;
myConnection.Open();
myCommand.ExecuteNonQuery();
DataGrid1.EditItemIndex=-1;
Show_data();
}
catch(System.InvalidCastException d)
{
Message.Text="Update failed" + d.ToString();
}
}
when running the program, no error occurs. but the data can not be updated. i don't know why. ( i am using oracle server)
can anyone help me? PLZ i am nearly crazy.
The following is my code:
private void Update_data(Object sender, DataGridCommandEventArgs e)
{
try
{
String updateCmd = "update rohsdb set Supplier=? where PortNo=?";
OleDbConnection myConnection= new OleDbConnection("Provider=MSDAORA; Data Source=***;User ID=system;Password=***");
OleDbCommand myCommand = new OleDbCommand(updateCmd,myConnection);
myCommand.Parameters.Add(new OleDbParameter("@PortNo",OleDbType.VarChar,50));
myCommand.Parameters["@PortNo"].Value= DataGrid1.DataKeys[(int)e.Item.ItemIndex];
myCommand.Parameters.Add(new OleDbParameter("@Supplier",OleDbType.VarChar,50));
myCommand.Parameters["@Supplier"].Value= ((TextBox)e.Item.FindControl("edit_supplier")).Text;
myConnection.Open();
myCommand.ExecuteNonQuery();
DataGrid1.EditItemIndex=-1;
Show_data();
}
catch(System.InvalidCastException d)
{
Message.Text="Update failed" + d.ToString();
}
}
when running the program, no error occurs. but the data can not be updated. i don't know why. ( i am using oracle server)
can anyone help me? PLZ i am nearly crazy.