strQuery = "insert orders (order_id,customer_id,customer_name,product_id,product_name,product_type,
values ('"+strClum[0]+"','"+strClum[1]+"',\
'"+strClum[2]+",'iNumber,fprice,fmoney)"
//iNumber, fprice,fmoney is varible  //出错了
strClum[] is CString //ok 
我的意思就是想用iNumber, fprice,fmoney 变量的值

解决方案 »

  1.   

    '"+strClum[2]+",'iNumber,fprice,fmoney)"这行变成
    '"+strClum[2]+"',iNumber,fprice,fmoney)"你可以将字符串打印出来到数据库中调试
      

  2.   

    fprict 和 fmoney 如果是字符串的话:
    strQuery.Format("insert orders (order_id, customer_id, customer_name, product_id, product_name, product_type) values (%d, %d, '%s', %d, '%s', '%s')", strClum[0],
    strClum[1], strClum[2], iNumber, fprice, fmoney);fprict 和 fmoney 如果是数字的话:
    strQuery.Format("insert orders (order_id, customer_id, customer_name, product_id, product_name, product_type) values (%d, %d, '%s', %d, %d, %d)", strClum[0],
    strClum[1], strClum[2], iNumber, fprice, fmoney);
      

  3.   

    哦,错了,values 后面的两个应该是 '%s',不是 %d
      

  4.   

    用insert into
    注意字段是char型的值两边写单引号,并且他们是char *的或者是cstring的
      

  5.   

    hopen(哈雷) ( ) 
     你的方法不行
      

  6.   

    语法是你上面写的,我只是随便改了一下。SQL 语法我没有理。
      

  7.   

    主要是说明 '%s' 与 %d 在 SQL 语句中的用法
      

  8.   

    你发到我的qq来,好像你写得不完整,我怎么看呀,发给我来分析,[email protected]