I have to call a stored procedure which includes two DateTime parameters.
I can do this interactively from within the IDE, by simply typing in the dates.
However when I do it programatically, the parameters do not appear to be passed correctly.
Code snippet:
Code: Select all
Var
TheDespatchDate : TDateTime;
TheReqDate : TDateTime;
begin
TheDespatchDate:=StrToDateTime(DespatchDate);
TheReqDate:=StrToDateTime(CustRequiredDate);
With MSStoredProc2 do
begin
ParamByName('CustRequiredDate').AsDateTime:=TheReqDate;
ParamByName('DespatchDate').AsDateTime:=TheDespatchDate;
Execute;
end;
end;
MSStoredProc2.ParamByName('DespatchDate').DataType => ftDateTime
MSStoredProc2.ParamByName('CustRequiredDate').DataType => ftDateTime
MSStoredProc2.ParamByName('DespatchDate').Value => '08/09/2009'
MSStoredProc2.ParamByName('CustRequiredDate').Value => '08/09/2009'
When execute is called a message is returned that DespatchDate cannot be NULL.
As I said, if I manually type these values into the Parameters page of the component, and click the Execute button, it works fine, so clearly the problem is not with the stored procedure itself.[/code][/quote]