请问怎样执行含中文的查询语句?

greatll 2004-01-12 03:11:15
数据库是oracle8,代码如下:
CRecordset rs(&m_db);
//...
rs.Open(CRecordset::snapshot, "select labelcode from label where labelname='单据'", CRecordset::readOnly);
if (rs.IsEOF() == 0) {
//...
}
这样总是得不到记录,但是如果直接在数据库中执行这句SQL是有数据的。如果SQL语句中没有中文的话就没问题,请问这是怎么回事?谢谢!
...全文
29 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
greatll 2004-01-17
  • 打赏
  • 举报
回复
这样根本编译不过啊。
TianChong 2004-01-15
  • 打赏
  • 举报
回复
这样试试:
rs.Open(CRecordset::snapshot, "select labelcode from label where labelname=_T("单据")", CRecordset::readOnly);
greatll 2004-01-14
  • 打赏
  • 举报
回复
是这样吗:
rs.Open(CRecordset::snapshot, _T("select labelcode from label where labelname='单据'"), CRecordset::readOnly);
也不行啊。
greatll 2004-01-13
  • 打赏
  • 举报
回复
还是不行啊:( 报错:
ORA-00904: "labelname": invalid identifier

请问是怎么回事?各位大侠帮帮忙吧。谢谢!
endicking 2004-01-13
  • 打赏
  • 举报
回复
你把试试你那些SQL语句转成Unicode看看
greatll 2004-01-13
  • 打赏
  • 举报
回复
还是不行:(
54yuandian 2004-01-13
  • 打赏
  • 举报
回复
buf = "单据";
sSql.Format("select labelcode from label where labelname='%s'",buf);
rs.Open(CRecordset::snapshot,sSql,CRecordset::readOnly);
这样试试
greatll 2004-01-13
  • 打赏
  • 举报
回复
同样的SQL我在PL/SQL中执行过,没问题。
不知是不是字符集的问题呢?我换用DB2就能查出来(Oracle和DB2的记录是相同的)。
jiudon 2004-01-13
  • 打赏
  • 举报
回复
你的这句:
rs.Open(CRecordset::snapshot, "select labelcode from label where labelname='单据'", CRecordset::readOnly);
是正确的啊,我用过中文的查询,跟英文的没有什么区别啊,都是可以的饿,
关注ing!
hamham 2004-01-12
  • 打赏
  • 举报
回复
rs.Open(CRecordset::snapshot, "select labelcode from label where [labelname]='单据'", CRecordset::readOnly);
greatll 2004-01-12
  • 打赏
  • 举报
回复
请问具体怎么加?是这样吗:
rs.Open(CRecordset::snapshot, "select labelcode from label where labelname='[单据]'", CRecordset::readOnly);
还是不行啊:(
lastman001 2004-01-12
  • 打赏
  • 举报
回复
加[]

4,011

社区成员

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

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