代码意思?
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;
请问这段代码是什么意思,请帮忙看一下,谢谢。
[解决办法]
这算那门子问题?就是一个查询。commandtext就是查询的语句;
在active:=true前面用showmessage(commandtext);可以看到最终的SQL语句
[解决办法]
procedure TFormroughexist.Button3Click(Sender: TObject);varstr1,str2:string;beginwith adod1 dobegin 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;//启动,执行sqlend;end;
[解决办法]
varchar是否都是数字?如果有非数字字符当然会出错
[解决办法]
把查询语句打印出来就看看不就知道了。。。或者在SQL的事件探测器里看
[解决办法]
你直接把语句写入memo,拷贝语句到Sqlserver查询分析器中试一试,就是你要的结果了。