pDb->ExecuteSQL(strSql)中,sql语句strSql中怎样可以实现像java中的String strSql="Insert into table(col) values("+colVal+")";

AdamsLee 2002-10-30 03:07:16
因为vc中的CString 不能像java的String一样可以
String strSql="Insert into table(col) values("+colVal+")";
那么sql语句中有的值是变量时怎么办?
...全文
83 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangbit 2002-10-30
  • 打赏
  • 举报
回复
要解说一下不?
%s对应str,因为是字符串所以要加''
%d对应n
_T()内只要包括"insert into TABLENAME(FIELD1,FILED2) values('%s',%d)"
zhf0021 2002-10-30
  • 打赏
  • 举报
回复
可以解决的,如:
strSQL.Format(_T("insert into TABLENAME(FIELD1,FILED2) values('%s',%d)"),str,n);

OK?

4,017

社区成员

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

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