I
igod
Unregistered / Unconfirmed
GUEST, unregistred user!
我需要动态查找,但是报错,高手看看是怎么回事?
var str:string;
flag:integer;
begin
flag:=0;
str:='';
coursequery.Active:=false;
with coursequery do
begin
databasename:='login';
close;
sql.Clear;
str:=str+'select * from t_score';
if idedit.Text<>'' then
begin
str:=str+' where xszh= '+idedit.Text;
flag:=1;
end;
if combobox1.Text<>'' then
begin
if flag=0 then str:=str+' where '
else
str:=str+' and ';
str:=str+' term= '+combobox1.text;
flag:=2;
end;
if bjedit.Text<>'' then
begin
if flag=0 then str:=str+' where '
else
str:=str+' and ';
str:=str+' bj= '+bjedit.Text+#39;
end;
sql.Add(str);
prepare;
open;
end;
var str:string;
flag:integer;
begin
flag:=0;
str:='';
coursequery.Active:=false;
with coursequery do
begin
databasename:='login';
close;
sql.Clear;
str:=str+'select * from t_score';
if idedit.Text<>'' then
begin
str:=str+' where xszh= '+idedit.Text;
flag:=1;
end;
if combobox1.Text<>'' then
begin
if flag=0 then str:=str+' where '
else
str:=str+' and ';
str:=str+' term= '+combobox1.text;
flag:=2;
end;
if bjedit.Text<>'' then
begin
if flag=0 then str:=str+' where '
else
str:=str+' and ';
str:=str+' bj= '+bjedit.Text+#39;
end;
sql.Add(str);
prepare;
open;
end;