查询问题 ( 积分: 10 )

  • 主题发起人 主题发起人 sun2001win
  • 开始时间 开始时间
S

sun2001win

Unregistered / Unconfirmed
GUEST, unregistred user!
小弟现在想把学校这栏的查询该成,当输入为"学校一,学校二,学校三时,。。。。"所有的学校的学生信息都显示出来。小弟以前的源码是:
procedure Tfm_by.bsSkinSpeedButton8Click(Sender: TObject);
var
sqlstr:string;
begin
{if (bsskincombobox1.Text<>'初中包月') and (bsskincombobox1.Text<>'高中包月') then
begin
showmessage('请选择包月类型!');
exit;
end;}
with dd.by do
begin
sqlstr:='select u_name as 姓名,tel as 手机号,adrees as 居住地,school as 学校,s_type as 业务类型,t_ding as 定制时间,t_jf as 计费时间,b_sy as 试用,b_qx as 取消 from sm_load where b_sy=:a and b_qx=:i';
if bsskinedit1.Text <>'' then sqlstr:=sqlstr+' and u_name=:b';
if bsskinedit2.Text <>'' then sqlstr:=sqlstr+' and tel=:c';
if bsskinedit3.Text <>'' then sqlstr:=sqlstr+' and adrees=:d';
if bsskinedit4.Text <>'' then sqlstr:=sqlstr+' and school like :e';
if bsskincombobox1.Text <>'' then sqlstr:=sqlstr+' and s_type=:f';
if (trim(bsskindateedit1.Text) <>'- -') and (trim(bsskindateedit1.Text) <>'/ /') then sqlstr:=sqlstr+' and t_ding>:g';
if (trim(bsskindateedit2.Text) <>'- -') and (trim(bsskindateedit2.Text) <>'/ /') then sqlstr:=sqlstr+' and t_jf>:h';
close;
sql.Clear;
sql.Add(sqlstr);
parambyname('a').AsBoolean:=bsskincheckradiobox1.Checked;
parambyname('i').AsBoolean:=bsskincheckradiobox2.Checked;
if pos(':b',sqlstr)>0 then parambyname('b').AsString:=bsskinedit1.Text;
if pos(':c',sqlstr)>0 then parambyname('c').AsString:=bsskinedit2.Text;
if pos(':d',sqlstr)>0 then parambyname('d').AsString:=bsskinedit3.Text;
if pos(':e',sqlstr)>0 then parambyname('e').AsString:='%'+bsskinedit4.Text+'%';
if pos(':f',sqlstr)>0 then parambyname('f').AsString:=bsskincombobox1.Text;
if pos(':g',sqlstr)>0 then parambyname('g').AsDateTime:=bsskindateedit1.Date;
if pos(':h',sqlstr)>0 then parambyname('h').AsDateTime:=bsskindateedit2.Date;
open;
end;
if bsskincombobox1.Text='初中包月' then bytype:=czby_type;
if bsskincombobox1.Text='高中包月' then bytype:=gzby_type;
bsskinspeedbutton9.Enabled:=true;
end;

希望高手给出答案
 
小弟现在想把学校这栏的查询该成,当输入为"学校一,学校二,学校三时,。。。。"所有的学校的学生信息都显示出来。小弟以前的源码是:
procedure Tfm_by.bsSkinSpeedButton8Click(Sender: TObject);
var
sqlstr:string;
begin
{if (bsskincombobox1.Text<>'初中包月') and (bsskincombobox1.Text<>'高中包月') then
begin
showmessage('请选择包月类型!');
exit;
end;}
with dd.by do
begin
sqlstr:='select u_name as 姓名,tel as 手机号,adrees as 居住地,school as 学校,s_type as 业务类型,t_ding as 定制时间,t_jf as 计费时间,b_sy as 试用,b_qx as 取消 from sm_load where b_sy=:a and b_qx=:i';
if bsskinedit1.Text <>'' then sqlstr:=sqlstr+' and u_name=:b';
if bsskinedit2.Text <>'' then sqlstr:=sqlstr+' and tel=:c';
if bsskinedit3.Text <>'' then sqlstr:=sqlstr+' and adrees=:d';
if bsskinedit4.Text <>'' then sqlstr:=sqlstr+' and school like :e';
if bsskincombobox1.Text <>'' then sqlstr:=sqlstr+' and s_type=:f';
if (trim(bsskindateedit1.Text) <>'- -') and (trim(bsskindateedit1.Text) <>'/ /') then sqlstr:=sqlstr+' and t_ding>:g';
if (trim(bsskindateedit2.Text) <>'- -') and (trim(bsskindateedit2.Text) <>'/ /') then sqlstr:=sqlstr+' and t_jf>:h';
close;
sql.Clear;
sql.Add(sqlstr);
parambyname('a').AsBoolean:=bsskincheckradiobox1.Checked;
parambyname('i').AsBoolean:=bsskincheckradiobox2.Checked;
if pos(':b',sqlstr)>0 then parambyname('b').AsString:=bsskinedit1.Text;
if pos(':c',sqlstr)>0 then parambyname('c').AsString:=bsskinedit2.Text;
if pos(':d',sqlstr)>0 then parambyname('d').AsString:=bsskinedit3.Text;
if pos(':e',sqlstr)>0 then parambyname('e').AsString:='%'+bsskinedit4.Text+'%';
if pos(':f',sqlstr)>0 then parambyname('f').AsString:=bsskincombobox1.Text;
if pos(':g',sqlstr)>0 then parambyname('g').AsDateTime:=bsskindateedit1.Date;
if pos(':h',sqlstr)>0 then parambyname('h').AsDateTime:=bsskindateedit2.Date;
open;
end;
if bsskincombobox1.Text='初中包月' then bytype:=czby_type;
if bsskincombobox1.Text='高中包月' then bytype:=gzby_type;
bsskinspeedbutton9.Enabled:=true;
end;

希望高手给出答案
 
表的结构都没说清楚,很容易用SQL语句实现.
 
表的结构都没说清楚,很容易用SQL语句实现.
 
后退
顶部