我做了如下,但运行不了:
     with adoquery1 do
     begin
          active:=true;
          close;
          sql.clear;
          sql.Add('select * from casestructure');
          Sql.Add('where (hole between '''+strtofloat(edt_hole.Text)+''' and '''+strtofloat(edt_holea.Text)+''')');
          prepared:=true;
          open;
      end;

解决方案 »

  1.   

    你用showmessage(sql.text);把你的sql语句输出一下
    也许就能看清楚什么毛病了。
      

  2.   

    你的hole是实数型吗?如果是:Sql.Add('select * from casestructure');
    Sql.Add('where hole between '+edt_hole.Text+' and '+edt_holea.Text);
      

  3.   

    Sql.Add(' where (hole between '''+strtofloat(edt_hole.Text)+''' and '''+strtofloat(edt_holea.Text)+''')');
    //where 之前应加空格
      

  4.   

    Sql.Add('select * from casestructure');
    Sql.Add('where hole >='+edt_hole.Text+' and <='+edt_holea.Text);
      

  5.   

    with adoquery1 do
         begin
              close;
              sql.clear;
              sql.Add('select * from casestructure where hole between :holestr and :holeend');
              Parameters.ParamByName('holestr').Value :=strtofloat(edt_hole.Text);
              Parameters.ParamByName('holestr').Value :=strtofloat(edt_holea.Text);
              open;
          end;
      

  6.   

    with adoquery1 do
         begin
              close;
              sql.clear;
              sql.Add('select * from casestructure where hole between :holestr and :holeend');
              Parameters.ParamByName('holestr').Value :=strtofloat(edt_hole.Text);
              Parameters.ParamByName('holeend').Value :=strtofloat(edt_holea.Text);
              open;
          end;
      

  7.   

    sql.Add('select * from casestructure');
              Sql.Add('where hole between '+edt_hole.Text+' and '+edt_holea.Text);
    试试看
      

  8.   

    注意:casestructure 和 where 之间千万别少了空格
      

  9.   

    我还有个问题想请教大家,我的数据库里面hole字段,它里面即有数字记录,也有文字记录,请问在筛选的过程中,怎么把那些是文字的记录都给过滤掉呢?要不然会出错的!