现在有个问题就是表t1的字段id是数据型字段,关于数据类型的转换大家帮我看一下。
sid:string
sid='1';
dx_dm.ADO_Query.SQL.Clear;
dx_dm.ADO_Query.SQL.Add('select * from t1 where id='''+sid+'''');
dx_dm.ADO_Query.ExecSQL;
这样系统又会说类型不匹配,应该怎么做

解决方案 »

  1.   

    ID是数据型字段吗?是的话SQL语句应该这样写
    dx_dm.ADO_Query.SQL.Add('select * from t1 where id='+sid);
      

  2.   

    dx_dm.ADO_Query.SQL.Add('select * from t1 where id='+inttostr(sid));
      

  3.   

    dx_dm.ADO_Query.SQL.Add('select * from t1 where id='+#39+sid+#39);
      

  4.   

    dx_dm.ADO_Query.SQL.Add('select * from t1 where id='+sid+'');
      

  5.   

    你可以一个保险的办法,sql.add(‘select * from table where id=:id1‘)
    queyr1.pampaer.pampabyname('id1').value:=strtoint(sid);