晨
晨空
Unregistered / Unconfirmed
GUEST, unregistred user!
有下面一段
datam.QY_yesterday.Close;
datam.QY_yesterday.SQL.Clear;
datam.QY_yesterday.SQL.Add('select * from datedata where datet=:a');
datam.QY_yesterday.Parameters.ParamByName('a').Value:=datetostr(date-1);
datam.QY_yesterday.Open;
datam.QY_today.Close;
datam.QY_today.SQL.Clear;
datam.QY_today.SQL.Add('select * from datedata where datet=:a');
datam.QY_today.Parameters.ParamByName('a').Value:=datetostr(date);
datam.QY_today.Open;
datam.QY_tomorrow.Close;
datam.QY_tomorrow.SQL.Clear;
datam.QY_tomorrow.SQL.Add('select * from datedata where datet=:a');
datam.QY_tomorrow.Parameters.ParamByName('a').Value:=datetostr(date+1);
datam.QY_tomorrow.Open;
现在我想把这三段结构基本相同的代码作成函数或过程,不知道应该该怎么写,我
菜得很,自己做了一下
procedure TFM_main.setevent(var query:tadoquery
datat:Tdatetime);
begin
query.close;
query.sql.clear;
query.sql.add('');
query.open;
end;
可是不行,请问大家该怎么办?
datam.QY_yesterday.Close;
datam.QY_yesterday.SQL.Clear;
datam.QY_yesterday.SQL.Add('select * from datedata where datet=:a');
datam.QY_yesterday.Parameters.ParamByName('a').Value:=datetostr(date-1);
datam.QY_yesterday.Open;
datam.QY_today.Close;
datam.QY_today.SQL.Clear;
datam.QY_today.SQL.Add('select * from datedata where datet=:a');
datam.QY_today.Parameters.ParamByName('a').Value:=datetostr(date);
datam.QY_today.Open;
datam.QY_tomorrow.Close;
datam.QY_tomorrow.SQL.Clear;
datam.QY_tomorrow.SQL.Add('select * from datedata where datet=:a');
datam.QY_tomorrow.Parameters.ParamByName('a').Value:=datetostr(date+1);
datam.QY_tomorrow.Open;
现在我想把这三段结构基本相同的代码作成函数或过程,不知道应该该怎么写,我
菜得很,自己做了一下
procedure TFM_main.setevent(var query:tadoquery
datat:Tdatetime);
begin
query.close;
query.sql.clear;
query.sql.add('');
query.open;
end;
可是不行,请问大家该怎么办?