在VC ++ 6.0中的SQL查询中传递Unicode字符串 [英] Passsing Unicode String in SQL Query in VC++ 6.0
问题描述
您好,专家,
我编写了一个程序来处理一些包含Unicode值的表.
我想通过传递Unicode值来搜索这些值.
我该怎么办?
我编写了以下代码,这似乎是正确的,但无法返回任何记录.
你能帮忙吗..很紧急..
我尝试了各种方法,但是没有用..
Hi Experts,
I have written one program which handles some Tables containing Unicode Values.
I want to search those values by passing a Unicode Value.
What should I DO??
I have write following code, which seems to be right, but could not return any records.
Can you help..Its urgent..
I tried out various ways but dont work..
int Get_Match_Vocables(unsigned short *usFindVoc,CRecordset &recOut)
{
CDatabase cn;
CString FieldValue1,FieldValue2,FieldValue3;
CDBVariant varvalue;
CString sqlStr;
CString csPwd,csUser,csServer,csDBName;
csPwd = "SQLServer2005";
csUser = "sa";
csDBName = "DeccanCollege";
csServer = "DECCANSERVER";
cn.OpenEx(_T("DRIVER={SQL Server};Pwd="+csPwd+";Uid="+csUser +";Database="+csDBName+";Server="+csServer),CDatabase::noOdbcDialog);
CRecordset rec(&cn);
sqlStr = "Select * from Vocablemaster where slvid in(Select slvid from slipvocmaster where binno between 165 and 169) and (VocDescSan like N''%"+CString(usFindVoc)+"%'')";
rec.Open( CRecordset::forwardOnly,sqlStr,CRecordset::none);
while(!rec.IsEOF())
{
rec.GetFieldValue((short)0,FieldValue1);
rec.GetFieldValue((short)1,FieldValue2);
rec.GetFieldValue((short)2,FieldValue3);
rec.MoveNext();
}
return (int)rec.GetRecordCount() ;
}
在上面的代码中,usFindVoc是传递给此函数的Unicode值.
当我检查它的十六进制值时,已发送给它的是正确的.
请帮助..如果有任何错误,请提出更正..
谢谢...
..... Victory ...........
In above code, usFindVoc is Unicode value, passed to this function.
When I checked its HEX value, it is correct which I have sent to it.
Please help .. if any mistakes then please suggest the corrections..
Thanks...
.....Victory...........
推荐答案
为什么不使用_T(< your character ="> ;)和LPCTSTR代替funcion参数中Unicode字符的无符号缩写?
Why you are not using _T("<your character="">") and LPCTSTR instead of unsigned short for Unicode character in the funcion arguments?
这篇关于在VC ++ 6.0中的SQL查询中传递Unicode字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!