/// <summary>
       /// 修改
       /// </summary>
       /// <param name="shipper"></param>
       /// <returns></returns>
       public static int UpdateShipper(Shipper shipper)
       {
           AccessHelper access = new AccessHelper();
           string sql = "update ShipperInfo set shipper_customerId=@customerId,shipper_fromBussinessName=@fromBussinessName," +
               "shipper_contactPerson=@contactPerson,shipper_address=@address,shipper_tel=@tel,shipper_orig=@orig,shipper_codTrade=@codTrade" +
               ",shipper_codid=@codid,shipper_pickupBy=@pickupBy,shipper_shipperSignature=@shipperSignature,shipper_shipDate=@shipDate," +
               "shipper_defaultTag=@defaultTag,shipper_re=@re,shipper_custom1=@custom1,shipper_custom2=@custom2,shipper_custom3=@custom3 where ID=@id";
           OleDbParameter[] para = new OleDbParameter[] 
           { 
                new OleDbParameter("@id",shipper.Id),
                new OleDbParameter("@customerId",shipper.Shipper_customerId),
                new OleDbParameter("@fromBussinessName",shipper.Shipper_fromBussinessName),
                new OleDbParameter("@contactPerson",shipper.Shipper_contactPerson),
                new OleDbParameter("@address",shipper.Shipper_address),
                new OleDbParameter("@tel",shipper.Shipper_tel),
                new OleDbParameter("@orig",shipper.Shipper_orig),
                new OleDbParameter("@codTrade",shipper.Shipper_codTrade),
                new OleDbParameter("@codid",shipper.Shipper_codid),
                new OleDbParameter("@pickupBy",shipper.Shipper_pickupBy),
                new OleDbParameter("@shipperSignature",shipper.Shipper_shipperSignature),
                new OleDbParameter("@shipDate",shipper.Shipper_shipDate),
                new OleDbParameter("@defaultTag",shipper.Shipper_defaultTag),
                new OleDbParameter("@re",shipper.Shipper_re),
                new OleDbParameter("@custom1",shipper.Shipper_custom1),
                new OleDbParameter("@custom2",shipper.Shipper_custom2),
                new OleDbParameter("@custom3",shipper.Shipper_custom3)
           };
           int result = access.ExecuteNonQuery(sql, para);
           return result;
       }
经多次测试,只要把SQL语句里面where ID=@id,此处的参数@id 换成 数字就OK,用参数就有问题(ID为access数据库表的自动增长列,即主键)
请各位指点迷津。。 。
 

解决方案 »

  1.   

    哦 没仔细看 还以为你是插入呢那是不是用参数 参数的类型没指定为 int型啊
     new OleDbParameter("@id",shipper.Id),改成这样试试呢
     new OleDbParameter("@id",Convert.toInt32(shipper.Id)),
      

  2.   

    这个我知道的 我在form里面已经转换了
      

  3.   

    没用过Access。楼主试试:
    new OleDbParameter(参数名, 类型[, 长度]){Value = 值},
      

  4.   

    你把
    new OleDbParameter("@id",Convert.toInt32(shipper.Id)),
    放到最后面试试呢
      

  5.   

    id放到最后ACCESS的参数认参数顺序而不是参数名字