qry1.SQL.Add('insert into T_user (id,username,password,count) values ('+id+','''+name+''','''+pwd+''',0)');
id是int类型的,
name,pwd是字符串类型,
哪位大哥帮我看下

解决方案 »

  1.   

    qry1.SQL.Add('insert into T_user (id,username,password,count) values ('+id+','''+name+''','''+pwd+''',0)');
    修改为:
    qry1.SQL.add('insert into T_user (id,username,password,count) values (
    +id+','+quotedstr(trim(name))+','+quotedstr(trim(pwd))+',0)' ');
      

  2.   

    IntToStr(id),用以用Quotedstr()函數處理單引號qry1.SQL.Add('insert into T_user (id,username,password,count) values ('+IntToStr(id)+','+Quotedstr(name)+','+Quotedstr(pwd)+',0)');
      

  3.   

    qry1.SQL.Add('insert into T_user (id,username,password,count) values ('+inttostr(id)+','#39+name+#39','#39+pwd+#39',0)');遇见在字符串中 需要输入单引号,我喜欢用#39代替
      

  4.   

    qry1.SQL.Add('insert into T_user (id,username,password,count) values ('+IntToStr(id) +','+name+','+pwd+',0)');我这样应该是对的吧