数据库模糊查找问题(30分)

F

F4nn

Unregistered / Unconfirmed
GUEST, unregistred user!
在delphi6中要实现模糊查找,该怎么做啊?为什么我写的代码无效的啊?他又不出错,但也
查不出记录!请大侠指教!
ADOquery1.Active :=false;
ADOquery1.SQL.Clear;
ADOquery1.SQL.Add('select * from bill where can_get=1 and STS_DATE like ''%'+fabricate+'%''');
ADOQUERY1.Open;
(注:fabricate在程序运行时等于2002-2)
本人想查找2002-2份的所有记录?还有什么办法可以实现日期查找的吗?我要实现的是只要我
选择年和月来查找!但我的数据库中的日期是有年月日的!请大侠指教!
 
sqlserver:
year(sts_date)=2002 and month(sts_date)=2

-----
http://www.8421.org
 
保证没有错:
var
RQ1,RQ2:string;
y,m,r:word;
begin
decodedate(你的日期,y,m,r);
RQ1:=inttostr(y)+'-'+inttostr(m)+'-1'
if m<>12 then
RQ2:=inttostr(y)+'-'+inttostr(m+1)+'-1'
else
RQ2:=inttostr(y+1)+'-1-1';
ADOquery1.Active :=false;
ADOquery1.SQL.Clear;
ADOquery1.SQL.Add('select * from bill where can_get=1 and STS_DATE>='''+RQ1+''''+' and STS_DATE<'''+RQ2+'''');
ADOQUERY1.Open;

 
var
RQ1,RQ2 :string;
y,m,r:word;
gauge:string;
begin
if combobox1.Text <>'' then
begin
if combobox2.Text <>'' then
gauge:=combobox1.Text+'-'+combobox2.Text ;
end
else
begin
showmessage('年栏不能为空');
end;
decodedate(gauge,y,m,r);
以上的代码中最后一句出错了!(也就是decodedate(gauge,y,m,r);这句出错了!)我也不懂怎么写
 
顶部