problem on oledbparameter on asp.net

Discussion in 'C#' started by alanX, Jun 30, 2006.

  1. #1
    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?
     
    alanX, Jun 30, 2006 IP
  2. gangwisch

    gangwisch Peon

    Messages:
    66
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try changing:
    String updateCmd = "update rohsdb set Supplier=? where PortNo=?";
    to
    String updateCmd = "update rohsdb set Supplier=@Supplier where PortNo=@PortNo";
     
    gangwisch, Dec 9, 2008 IP