Reputation: 1
I keep on getting that my sdate got no Value.
procedure TForm1.Button12Click(Sender: TObject);
var
sdate : string;
begin
sDate := inputbox('Date', 'Enter Date', '');
CDQuery.Active := False;
CDQuery.SQL.Text := 'Select Ownername, DateOfBirth from Owner_Table where DateOfBirth < Datevalue(sdate)';
CDQuery.Active := True;
end;
Upvotes: 0
Views: 507
Reputation: 3151
You did not concatenate sDate with your SQL statement. You just put it inside the string. You need to do something like this:
sDate := inputbox('Date', 'Enter Date', '');
CDQuery.Active := False;
CDQuery.SQL.Text := 'Select Ownername, DateOfBirth from Owner_Table where DateOfBirth < DateValue(:sdate)';
CDQuery.Parameters.ParamByName('sdate').Value := sDate;
CDQuery.Active := True;
Upvotes: 1