/// <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数据库表的自动增长列,即主键)
请各位指点迷津。。 。
new OleDbParameter("@id",shipper.Id),改成这样试试呢
new OleDbParameter("@id",Convert.toInt32(shipper.Id)),
new OleDbParameter(参数名, 类型[, 长度]){Value = 值},
new OleDbParameter("@id",Convert.toInt32(shipper.Id)),
放到最后面试试呢