sql查询语句中使用vc定义的变量
SELECT stu_num,stu_name,stu_style,stu_system,stu_class FROM student WHERE stu_num='+i+'";
请问在sql查询语句中使用vc定义的变量是 '+变量+' 的形式么?
在运行后报错:在将varchar值'+i+'转换成数据类型int时失败、
我定义的i是下面这样的:
int i;
i=GetDlgItemInt(IDC_chaxun);
有没人帮我看看,指导指导,谢谢拉!
[解决办法]
CString strSql;strSql.Format("SELECT stu_num,stu_name,stu_style,stu_system,stu_class FROM student WHERE stu_num='%d'",i);
[解决办法]
int i;i=GetDlgItemInt(IDC_chaxun);CString str;str.Format("%d",i);CString strSql = "SELECT stu_num,stu_name,stu_style,stu_system,stu_class FROM student WHERE stu_num='"+str+"'";