我用query ,edit,button想要查询与输入edit中数据一致的记录,但是不知道哪里错了 var a:integer;
begin
a:=strtoint(edit1.Text);
with query1 do
begin
Close;
SQL.Clear;
SQL.Add('select  * from abc where id=');
sql.add('''');
sql.add(a);
sql.add('''');
open;
end;

解决方案 »

  1.   

    sql.add('select * fro abc where id=');
    sql.add(IntToStr(a));
    open;
      

  2.   

    var a:integer;
    begin
    a:=strtoint(edit1.Text);
    with query1 do
    begin
    Close;
    SQL.Clear;
    SQL.Add('select  * from abc where id='''+a+''' ');
    open;
    end;
      

  3.   

    begin
    with query1 do
    begin
    Close;
    SQL.Clear;
    SQL.Add('select  * from abc where id='+edit1.Text);
    open;
    end;
    这样就可以了
      

  4.   

    嗯,需要变一下为:
    SQL.Add('select  * from abc where id='''+edit1.Text+''' ');
      

  5.   

    wslashy 说的对、不需要定义变量a,直接用 edit1.text 掉入~
      

  6.   

    SQL.Add('select  * from abc where id='+trim(edit1.Text));
      

  7.   

    cjfzy SQL.Add('select  * from abc where id='+trim(edit1.Text));
    里面的trim 是个什么函数,谢谢~~
      

  8.   

    还有啊,就是在里面加的'  具体怎么加啊,看起来很乱,都有什么作用,例如上面说的
    SQL.Add('select  * from abc where id='''+edit1.Text+''' ');
    连接edit1.text前面怎么那么多' 啊~
      

  9.   

    SQL.Add('select  * from abc where id='+trim(edit1.Text));
    SQL.Add('select  * from abc where id='''+edit1.Text+''' ');都可以用,一个用在string型,一个用在integer型的。但trim()是什么意思呢?还有我看到过有书中用quotedstr(),都是什么意思?
      

  10.   

    trim就是把首尾多余的空格去掉
      

  11.   

    我也明白了。
    不过我还有个问题,如果不是整型和string型,怎么写呢?
      

  12.   

    回复人: bee2518(真棒) ( ) 信誉:100  2003-04-12 16:30:00  得分:0 
     
     
      begin
    with query1 do
    begin
    Close;
    SQL.Clear;
    SQL.Add('select  * from abc where id='+edit1.Text);
    open;
    end;
    这样就可以了  
     
    -------
    就是上面那样了,省事,
    a 是INT;