这段代码是判断输入的序号是否合法,有时会两个客户端同时使用,在离开COMBOBOX6时,有时会过很久才反应过来,有时又很快,所以请教是不是我的SQL语名不对呀,请教了.
procedure TForm2.ComboBox6Exit(Sender: TObject);var a3,a4,a5,a6:integer;
begin
if combobox6.text='' then
begin
showmessage('序号不能为空呀!');
exit;
end;
with mydata.ADOQuery2 do
begin
close;
sql.clear;
sql.Add('select max(序号)as 序号 from cw_jjb where 订单号码=:a and 公司款号=:b and 分批=:c');
parameters.ParamByName('a').Value :=trim(combobox1.text);
parameters.ParamByName('b').Value :=trim(combobox3.text);
parameters.ParamByName('c').Value :=trim(combobox8.text);
open;
end;
// showmessage(mydata.ADOQuery2.fieldbyname('序号').Value);
if mydata.adoquery2.fieldbyname('序号').value=null then
begin
exit;
end
else
begin
a3:=mydata.ADOQuery2.fieldbyname('序号').Value;
a4:=strtoint(trim(combobox6.text));
if a4<=a3 then
begin
showmessage('您输入的"序号"小于或等于现有订单工序号,请重新输入!');
combobox6.SetFocus;
exit;
end;with mydata.ADOQuery2 do
begin
close;
sql.clear;
sql.Add('select max(序号)as 序号 from cw_jjb where 订单号码=:a and 公司款号=:b and 分批=:c');
parameters.ParamByName('a').Value :=trim(combobox1.text);
parameters.ParamByName('b').Value :=trim(combobox3.text);
parameters.ParamByName('c').Value :=trim(combobox8.text);
open;
end;
a5:=mydata.ADOQuery2.fieldbyname('序号').Value;
a6:=strtoint(trim(combobox6.text));
if a4-a3>1 then
begin
showmessage('您输入的"序号"不连续,请重新输入!');
combobox6.SetFocus;
exit;
end;
end;end;
procedure TForm2.ComboBox6Exit(Sender: TObject);var a3,a4,a5,a6:integer;
begin
if combobox6.text='' then
begin
showmessage('序号不能为空呀!');
exit;
end;
with mydata.ADOQuery2 do
begin
close;
sql.clear;
sql.Add('select max(序号)as 序号 from cw_jjb where 订单号码=:a and 公司款号=:b and 分批=:c');
parameters.ParamByName('a').Value :=trim(combobox1.text);
parameters.ParamByName('b').Value :=trim(combobox3.text);
parameters.ParamByName('c').Value :=trim(combobox8.text);
open;
end;
// showmessage(mydata.ADOQuery2.fieldbyname('序号').Value);
if mydata.adoquery2.fieldbyname('序号').value=null then
begin
exit;
end
else
begin
a3:=mydata.ADOQuery2.fieldbyname('序号').Value;
a4:=strtoint(trim(combobox6.text));
if a4<=a3 then
begin
showmessage('您输入的"序号"小于或等于现有订单工序号,请重新输入!');
combobox6.SetFocus;
exit;
end;with mydata.ADOQuery2 do
begin
close;
sql.clear;
sql.Add('select max(序号)as 序号 from cw_jjb where 订单号码=:a and 公司款号=:b and 分批=:c');
parameters.ParamByName('a').Value :=trim(combobox1.text);
parameters.ParamByName('b').Value :=trim(combobox3.text);
parameters.ParamByName('c').Value :=trim(combobox8.text);
open;
end;
a5:=mydata.ADOQuery2.fieldbyname('序号').Value;
a6:=strtoint(trim(combobox6.text));
if a4-a3>1 then
begin
showmessage('您输入的"序号"不连续,请重新输入!');
combobox6.SetFocus;
exit;
end;
end;end;
能不用中文就不要用,最好用英文 parameters.ParamByName('a').Value :=trim(combobox1.text);
parameters.ParamByName('b').Value :=trim(combobox3.text);
parameters.ParamByName('c').Value :=trim(combobox8.text);
改为
parameters.item[0].Value :=trim(combobox1.text);
parameters.item[1].Value :=trim(combobox3.text);
parameters.item[2].Value :=trim(combobox8.text);
这样效率要高点
如果cpu不高应该是网络问题,服务器高的话就要跟踪SQL看一下,建个索引试试
parameters.ParamByName('a').Value :=trim(combobox1.text);
parameters.ParamByName('b').Value :=trim(combobox3.text);
parameters.ParamByName('c').Value :=trim(combobox8.text); parameters.item[0].Value :=trim(combobox1.text);
parameters.item[1].Value :=tri…
parameters.item[2].value:=trim...
代码不复杂,没有问题了,你也说了是在有的机子上很慢,运行的时候,查看下cpu使用率看下机器的性能,你的机子要是内存小,肯定慢了,要是这个没问题,可能就是和数据库的通讯时间长了,可以给数据表建立索引.