I am passing MySQL query using UniQuery in Delphi and it is returing NULL.
I already change the date format in the property of my TDBDateTimeEditEh to match with mysql format yyyy-mm-dd and pass this to my string variable at runtime.
Here's my code:
procedure TfrmPayroll.Button1Click(Sender: TObject);
var
DateRangeQry, StartDate, EndDate : string;
begin
StartDate := dthStart.Text;
EndDate := dthEnd.Text;
DateRangeQry := 'SELECT * FROM mytimesheet WHERE Date >= '+ StartDate +' AND date <= '+ EndDate +'';
//ShowMessage(StartDate +' to '+ EndDate); // result yyyy-mm-dd to yyyy-mm-dd
with dm_u.dmPayroll do
begin
uqMyTimesheet.SQL.Clear;
uqMyTimesheet.sql.Text := DateRangeQry;
uqMyTimesheet.ExecSQL;
cdsMyTimesheet.Refresh;
end;
end;
I did check the value in the showmessage and it is matching the date format in mysql.
I supposed my codes about would generate range of records from the database within the date range specified but no avail.
I will appreciate any help from you guys.
Updates:
uqMyTimesheet.SQL.Clear;
is pointless. Setter of propertyText
callsClear
withinBeginUpdate
..EndUpdate
block. – Peter Wolf