WideCharToMultiByte 和 CString之间的转换
CString ExcuteSql("insert into ashare_ordwth(REC_NUM,DATE1,TIME1,reff,acc,stock,bs,price,qty,status,owflag,ordrec,firmid,branchid,checkord) values (a1.nextval,'"+
strTime1+
"','"+
strDate1+"',ordwth_reff.nextval,'"+cstrAcc+"','"+cstrStock+"','"+
bs+"','"+cstrPrice+"','"+cstrQty+"','R','ORD','','JZGF','JZGF',0)");
WideCharToMultiByte(CP_ACP,0,ExcuteSql,ExcuteSql.GetLength(),sql,255,NULL,NULL);
pRst = dbOper.ExecuteWithResSQL(sql);
在我使用Unicode字符集的时候,会报一个 error C2678: 二进制“+”: 没有找到接受“const char [142]”类型的左操作数的运算符(或没有可接受的转换)
使用多字节字符集的时候,上面一个问题是没了,但是WideCharToMultiByte函数会报一个“WideCharToMultiByte”: 不能将参数 3 从“CString”转换为“LPCWSTR”错误
我的想法是把用CString把sql语句拼接起来,转换成char* 类型的字符串作为参数,使用dbOper.ExecuteWithResSQL函数来执行sql语句