c# 使用odbc连接access 遇到的问题。急急急 在线等解决办法

lihui_life 2016-07-05 04:33:20
string sql = string.Format(@"UPDATE t_guest SET GUESTTYPE='{0}',GROUPID='{1}',
[NAME]='{2}',SEX='{3}',BIRTHDAY='{4}',IDTYPE='{5}',IDCODE='{6}',DISTRICTID='{7}',
[ADDRESS]='{8}',HOTELID='{9}',ROOMID='{10}',LTIME='{11}',LWAITER='{12}',ETIME='{13}',
EWAITER='{14}',PHOTO=?,FIRSTNAME='{15}',LASTNAME='{16}',
COUNTRY='{17}',NATION='{18}',SUMMARY='{19}',CREATETIME='{20}',
SCANTIME='{21}' WHERE GUESTID='{22}' ", guestType, groupId, model.ID_Name,
model.ID_Sex == "男" ? "1" : "2", model.ID_Birth.Replace("-", ""), idType,
model.ID_ID, districtId, model.ID_Addr, hotelId, model.Sign_RoomID, model.Oper_Date.ToString("yyyyMMddHHmm")
, string.IsNullOrEmpty(model.Oper_ID) ? "admin" : model.Oper_ID, "", "", "", "", country, nation,
sumMary, DateTime.Now.ToString("yyyyMMddHHmm"), DateTime.Now.ToString("yyyyMMddHHmm"), guestId);
System.Data.Odbc.OdbcParameter[] parm ={
// DBhelperForODBC.GetParameter("@GUESTTYPE",OdbcType.VarChar,guestType),
// DBhelperForODBC.GetParameter("@GROUPID",OdbcType.VarChar,groupId),
// DBhelperForODBC.GetParameter("@NAME",OdbcType.VarChar,model.ID_Name),
// DBhelperForODBC.GetParameter("@SEX",OdbcType.VarChar,model.ID_Sex=="男" ? "1" : "2"),
// DBhelperForODBC.GetParameter("@BIRTHDAY",OdbcType.VarChar,model.ID_Birth.Replace("-","")),
// DBhelperForODBC.GetParameter("@IDTYPE",OdbcType.VarChar,idType),
// DBhelperForODBC.GetParameter("@IDCODE",OdbcType.VarChar,model.ID_ID),
// DBhelperForODBC.GetParameter("@DISTRICTID",OdbcType.VarChar,districtId),
// DBhelperForODBC.GetParameter("@ADDRESS",OdbcType.VarChar,model.ID_Addr),
// DBhelperForODBC.GetParameter("@HOTELID",OdbcType.VarChar,hotelId),
// DBhelperForODBC.GetParameter("@ROOMID",OdbcType.VarChar,model.Sign_RoomID),
// DBhelperForODBC.GetParameter("@LTIME",OdbcType.VarChar,model.Oper_Date.ToString("yyyyMMddHHmm")),
// DBhelperForODBC.GetParameter("@LWAITER",OdbcType.VarChar,string.IsNullOrEmpty( model.Oper_ID) ? "admin" : model.Oper_ID),
// DBhelperForODBC.GetParameter("@ETIME",OdbcType.VarChar,""),
// DBhelperForODBC.GetParameter("@EWAITER",OdbcType.VarChar,""),
new OdbcParameter("@PHOTO",OdbcType.Binary,100000),
// DBhelperForODBC.GetParameter("@PHOTO",OdbcType.Binary,model.ID_Bmp),
// DBhelperForODBC.GetParameter("@FIRSTNAME",OdbcType.VarChar,""),
// DBhelperForODBC.GetParameter("@LASTNAME",OdbcType.VarChar,""),
// DBhelperForODBC.GetParameter("@COUNTRY",OdbcType.VarChar,country),
// DBhelperForODBC.GetParameter("@NATION",OdbcType.VarChar,nation),
// DBhelperForODBC.GetParameter("@SUMMARY",OdbcType.VarChar,sumMary),
// DBhelperForODBC.GetParameter("@CREATETIME",OdbcType.VarChar,DateTime.Now.ToString("yyyyMMddHHmm")),
// DBhelperForODBC.GetParameter("@SCANTIME",OdbcType.VarChar,DateTime.Now.ToString("yyyyMMddHHmm")),
// DBhelperForODBC.GetParameter("@GUESTID",OdbcType.VarChar,guestId)
};
DBhelperForODBC.ExecuteSql(sql, parm);




以上是测试代码
如果直接拼接sql 不会报错,但二进制保存不全好像被截断,如果使用OdbcParameter 参数形式,则会在传二进制处报错,提示:ODBC Microsoft Access 驱动程序]非法的精确度数值, 求解?
...全文
286 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lihui_life 2016-07-05
  • 打赏
  • 举报
回复
引用 1 楼 shingoscar 的回复:
去掉个0试试,access应该有限制
new OdbcParameter("@PHOTO",OdbcType.VarBinary,model.ID_Bmp.Length), 现在用的这个 还是不行
Poopaye 2016-07-05
  • 打赏
  • 举报
回复
去掉个0试试,access应该有限制

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧