I have an SQLite table containing 4 items: ID, ITEM, DESC, DATE
I am using the sqlite3dataset component and a datasource. I also have a dbgrid that is using the datasourse and sqlite3dataset components.
Normally the query for this table is set to 'select * from item' which contains all the records. Three fields in the database have a 'search' button to allow searching on the record set. For the DATE 'search' button I use a calendar dialog to select a date and then I set a dbquerry with the results of the calendar dialog to search for records entered on that date. Here's (I hope) enough code for all to see what's going on:
...
var
main_form: Tmain_form;
search_time_edit: string;
...
procedure Tmain_form.Button10Click(Sender: TObject);
var found_it: boolean;
var tstr: string;
begin
if CalendarDialog1.Execute then
search_time_edit := datetostr(CalendarDialog1.Date);
found_it := false;
tstr := 'SELECT * FROM ITEM WHERE ITEM.DATE = ' + '''' + search_time_edit + '''' + ';';
dmr.sqlite_ds_item1.close;
dmr.sqlite_ds_item1.SQL := tstr;
dmr.sqlite_ds_item1.open;
try
if Form2.ShowModal = mrOk then begin
when the grid opens, it either displays all records or none.
I started off with 'select * from item where date = tstr'
Then I tried adding quotes to the date, and it still doesn't work.
I don't understand why it is so difficult to search a date field for a given date. All help is appreciated.
Thanks