sql: select ccn,po_num,a_dte1,a_qty1,a_usr1,a_dte2,a_qty2,a_usr2 from p
     where ccn='xxxxxxxxxx' and p.po_num between 'min_xxxxxxx' and 'max_xxxxxxx'现在我定义如下:
da.UpdateCommand=new OleDbCommand("update etsd_del_con set a_dte1=@a_dte1,
a_qty1 = @a_qty1,a_usr1=@a_usr1,a_dte2=@a_dte2,a_qty2 = @a_qty2,a_usr2=@a_usr2 
where ccn=@ccn and po_num=@po_num );da.UpdateCommand.Parameters.Add("@a_dte1", OleDbType.Date);
da.UpdateCommand.Parameters.Add("@a_qty1", OleDbType.Numeric);
da.UpdateCommand.Parameters.Add("@a_usr1", OleDbType.VarChar);
da.UpdateCommand.Parameters.Add("@a_dte2", OleDbType.Date);
da.UpdateCommand.Parameters.Add("@a_qty2", OleDbType.Numeric);
da.UpdateCommand.Parameters.Add("@a_usr2", OleDbType.VarChar);
da.UpdateCommand.Parameters.Add("@ccn", OleDbType.VarChar);
da.UpdateCommand.Parameters.Add("@po_num", OleDbType.VarChar);这样设置参数后,为什么提示
One or more errors occurred during processing of command.
ORA-00936: missing expression?请大侠们帮忙修改下,谢谢!

解决方案 »

  1.   

    楼主,错误指出非常明显:sql语句表达式错误!你的参数都没有赋值!其中:da.UpdateCommand.Parameters.Add("@a_qty1", OleDbType.Numeric).Value= 55;//类型、赋值同一个语句
      

  2.   

    额,我是要批量更新一个DataTable表中已经编辑了的数据到数据库中去,
    这个DataTable表是用上面SQL语句查询出来的,但是数据库中对应的表无主键,所以需要手动设置,请帮忙下,我该如何弄啊!
      

  3.   

    da.UpdateCommand.Parameters.Add()
    未调用此方法
      

  4.   

    “但是数据库中对应的表无主键”,没关系,你不写where ,就是针对整个表的;如果要精确定位,就在where语句报条件写出来、、、
      

  5.   

    OleDbConnection conn=null;
    OleDbDataAdapter da=null;
    OleDbCommandBuilder builder;
    DataSet ds=null;
    try
       {
            conn = new OleDbConnection(ApplicationConfig.CONNECTION_STRING);
            da = new OleDbDataAdapter();
            da.SelectCommand = new OleDbCommand(sql, conn);
            builder = new OleDbCommandBuilder(da);
            OleDbCommand cmdUpdate = new OleDbCommand("update etsd_del_con set a_dte1=@a_dte1,a_qty1=@a_qty1,a_usr1=@a_usr1,"                                       + "a_dte2=@a_dte2,a_qty2 = @a_qty2,a_usr2=@a_usr2 "
    +" where ccn=@ccn and po_num=@po_num ");
             da.UpdateCommand = cmdUpdate;
             da.UpdateCommand.Parameters.Add("@a_dte1", OleDbType.Date);
             da.UpdateCommand.Parameters.Add("@a_qty1", OleDbType.Numeric);
             da.UpdateCommand.Parameters.Add("@a_usr1", OleDbType.VarChar);
             da.UpdateCommand.Parameters.Add("@a_dte2", OleDbType.Date);
             da.UpdateCommand.Parameters.Add("@a_qty2", OleDbType.Numeric);
             da.UpdateCommand.Parameters.Add("@a_usr2", OleDbType.VarChar);
             da.UpdateCommand.Parameters.Add("@ccn", OleDbType.VarChar);
             da.UpdateCommand.Parameters.Add("@po_num", OleDbType.VarChar);
             da.UpdateCommand.UpdatedRowSource = UpdateRowSource.None;
             conn.Open();
             ds = new DataSet();
             da.Fill(ds);
             DataTable dt01 = ds.Tables[0];
             for (int j = 0; j < readyTab.Rows.Count; j++)
             {
                  //修改整个dt01中的数据代码。
             }
             da.Update(ds);
        }
        catch
        {
         }
    现在我的这代码该怎么改啊?请帮忙下呀!
      

  6.   


    UpdateCommand="UPDATE [intbl423] SET [factor1] = @factor1 WHERE [factorlevel] = @factorlevel";UpdateCommand.Parameters.Add("@factorlevel",SqlDbType.NVarChar);
    UpdateCommand.Parameters.Add["@factorlevel"].Value="factorlevel";UpdateCommand.Parameters.Add("@factor1",SqlDbType.Float);
    UpdateCommand.Parameters.Add["@factor1"].Value="factor1";执行命令进行更新。
      

  7.   

    UpdateCommand 定义是什么?OleDbCommand?还是String?
    da.UpdateCommand.Parameters.Add["@a_dte1"].Value = "a_dte1";
    我这样定义,出现了错误:
    编译器错误消息: CS0021: 无法将带 [] 的索引应用于“方法组”类型的表达式
    请帮忙下!
      

  8.   

    OleDbCommand cmdUpdate = new OleDbCommand("update etsd_del_con set a_dte1=@a_dte1,a_qty1=@a_qty1,a_usr1=@a_usr1," + "a_dte2=@a_dte2,a_qty2 = @a_qty2,a_usr2=@a_usr2 "
    +" where ccn=@ccn and po_num=@po_num ");最后自己解决:
    OleDbCommand cmdUpdate = new OleDbCommand("update etsd_del_con set a_dte1=?,a_qty1=?,a_usr1=?," + "a_dte2=?,a_qty2 = ?,a_usr2=? "
    +" where ccn=? and po_num=? ");
    (注:sqlClient格式是:po_num=@po_num 
             oledb格式是:po_num=? 
      oracleClient格式是:po_num=:ppo_num)
    在批量更新时,记得这格式。