思路;
1 把cstring 类型 转为 string
2 string 转 char 数组
3 sprintf 写入数组
string 转 char 数组函数
-
char* zhuanhuan(std::string src)
-
{
-
char *dst = new char[255];
-
int i;
-
int j=src.length();
-
for(i=0;i <src.length();i++)
-
dst[i]=src[i];
-
dst[i] = '\0';
-
return dst;
-
}
代码參考:
-
openAccess();
-
CString cmbParam = L"SelfImprovement";
-
std::string a1=(CT2A)(cmbParam.GetBuffer());
-
char buff[256] = {0};
-
sprintf(buff, "select * from tb_YCType where YCName = '%s' order by YCType desc",zhuanhuan(a1));
-
m_pRecordset = m_pConnection->Execute(buff, &RecordsAffected, adCmdText);
这个算一个有用的方法吧。其它方法我还没用到,也欢迎有好方法的能够交流!
posted @
2017-05-25 15:34
zsychanpin
阅读(
356)
评论()
编辑
收藏
举报