一个SQL语句的问题

huakun 2003-12-26 02:01:22
有一个表User 里面有一个字段,字段名为Employee(数字类型)

int aa=1(整型变量aa,初始值赋为1)
1.update User set Employee=1;

2.update User set Employee=aa;

上面这两条语句,第一条语句执行有用,而第二条语句执行时就出错

出错提示好像是说"期待参数为1"

请问这是什么原因
...全文
57 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fificake1 2003-12-26
  • 打赏
  • 举报
回复
int aa = 1;
strsql.Format("update User set Employee=%d",aa);
最好别用数字型,容易出错,用字符串做字段,转换一下最保险。
spwnihao 2003-12-26
  • 打赏
  • 举报
回复
strSQL = Format(""update User set Employee=%d",aa);
DebugXP 2003-12-26
  • 打赏
  • 举报
回复
strsql.Format("update User set Employee=%d",aa);

m_pRecordset->Open((_variant_t)strsql,
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
arvid_gs 2003-12-26
  • 打赏
  • 举报
回复
"update User set Employee=" + aa ;
arvid_gs 2003-12-26
  • 打赏
  • 举报
回复
Employee(数字类型)
Employee=aa; 是个字符串

4,017

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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