sql 语句问题!
数据库是access ,请问我这条sql 语句怎么行不通呢?
Var
Sql_Str:String;
D1,D2:TDateTime;
begin
D1:=DBeginDate.DateTime ;
D2:=EEndDate.DateTime;
Sql_Str:='Select Code_id Code_Type ,Frim_id , Pro_Name from BaseInfo
Where Apply_Date between :D1 and :D2 ';
if Trim(CodeN.Text)<>'' then
Sql_Str:=Sql_Str+' and Code_id like ''%'+CodeN.Text+'%''';
if Trim(CodeType.Text)<>'' then
Sql_Str:=Sql_Str+' and Code_Type like ''%'+CodeType.Text+'%''';
if Trim(CorPoration.Text)<>'' then
Sql_Str:=Sql_Str+' and CorPoration like ''%'+CorPoration.Text+'%''';
if Trim(FrimEdt.Text)<>'' then
Sql_Str:=Sql_Str+' and Frim_id Like ''%'+FrimEdt.Text+'%''';
Sql_Str:=Sql_Str+' order by Code_id ';
With DM.InsertInfoQue do
begin
Close;
Sql.Clear;
Sql.Add(Sql_Str);
Parameters.ParamByName('D1').Value:=Min(D1, D2);
Parameters.ParamByName('D2').Value:=Max(D1, D2);
Open;
end;