procedure TFormroughexist.Button3Click(Sender: TObject);
var
str1,str2:string;
begin
with adod1 do
begin
 active:=false;
 commandtext:='select * from roughexist where material='+''''+trim(edit4.text)+''''+' and cast(RIGHT(spec, 10-CHARINDEX('+''''+'x'+''''+',lower(spec))) as float)>='+''''+trim(edit5.text)+''''+' and cast(RIGHT(spec, 10-CHARINDEX('+''''+'x'+''''+',lower(spec))) as float)<= '+''''+trim(edit6.text)+'''';
 active:=true;
end;
end;请问这段代码是什么意思,请帮忙看一下,谢谢。

解决方案 »

  1.   

    这算那门子问题?就是一个查询。commandtext就是查询的语句;在active:=true前面用showmessage(commandtext);可以看到最终的SQL语句
      

  2.   


    procedure TFormroughexist.Button3Click(Sender: TObject);
    var
    str1,str2:string;
    begin
    with adod1 do
    begin
     active:=false; //设置adod1adod1为不活动状态//下面是sql语句
     commandtext:='select * from roughexist where material='+''''+trim(edit4.text)+''''+' and cast(RIGHT(spec, 10-CHARINDEX('+''''+'x'+''''+',lower(spec))) as float)>='+''''+trim(edit5.text)+''''+' and cast(RIGHT(spec, 10-CHARINDEX('+''''+'x'+''''+',lower(spec))) as float)<= '+''''+trim(edit6.text)+'''';
     active:=true;//启动,执行sql
    end;
    end;
      

  3.   

    我现在查询现在这个对话框:将数据类型 varcher 转换为 float 时出错,
    请问需要如何修改数据类型呀,
      

  4.   

    varchar是否都是数字?如果有非数字字符当然会出错
      

  5.   

    把查询语句打印出来就看看不就知道了或者在SQL的事件探测器里看
      

  6.   

    你直接把语句写入memo,拷贝语句到Sqlserver查询分析器中试一试,就是你要的结果了。