关于sql语句的问题,我想将二维数组的值存入数据库中,二维数组为double (*)p【4】;行数为变量nRow
写了一个很简单的sql语句
for(int i=0;i<nRow;i++)
{
_variant_t strSQL="insert into tycdata(fgj,fnd,fyl,fccxs) values("+p[i][0]+","+p[i][1]+","+p[i][2]+","+p[i][3]+")";
if(theApp->executeADO(theApp->m_pAdoset,strSQL))//已经定义函数,不存在问题
{
}结果老是提示错误,point additional requiers integral operand错误,通过不了编译。插入字符串这种写法又没有错误,是不是vc中的sql语句对非、字符穿的变量有另外的写法,各位大哥帮帮忙,不胜感激!!
写了一个很简单的sql语句
for(int i=0;i<nRow;i++)
{
_variant_t strSQL="insert into tycdata(fgj,fnd,fyl,fccxs) values("+p[i][0]+","+p[i][1]+","+p[i][2]+","+p[i][3]+")";
if(theApp->executeADO(theApp->m_pAdoset,strSQL))//已经定义函数,不存在问题
{
}结果老是提示错误,point additional requiers integral operand错误,通过不了编译。插入字符串这种写法又没有错误,是不是vc中的sql语句对非、字符穿的变量有另外的写法,各位大哥帮帮忙,不胜感激!!
从而减少程序中的处理和代码量。
CString strSql;
strSql.Format("insert into tycdata(fgj,fnd,fyl,fccxs) values(%s,%s,%s,%s",p[i][0],p[i][1],p[i][2],p[i][3]);
从而减少程序中的处理和代码量。
============================================================================呵呵,也要具体情况具体分析啊。如果很复杂的关联,我宁愿在数据库里建view.
用Format()函数
CString strSql;
strSql.Format("insert into tycdata(fgj,fnd,fyl,fccxs) values(%s,%s,%s,%s",p[i][0],p[i][1],p[i][2],p[i][3]);-----------------------------------
正解!