0

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;
Filburt
  • 17,626
  • 12
  • 64
  • 115
  • [What is the exact error message? Is it a compiler error or a runtime error? In what line does it occur?](http://stackoverflow.com/questions/how-to-ask) – O. R. Mapper Feb 04 '14 at 09:39

1 Answers1

1

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;
M.Sameer
  • 3,072
  • 1
  • 24
  • 37
  • welcome .. please mark it as accepted answer to improve your acceptance rating and encourage others to answer your questions in the future. – M.Sameer Feb 04 '14 at 12:49