Locate a record in DBGrid
Moderators: gto, bravecobra
Locate a record in DBGrid
I couldn't find the documentation on ZeosLib anyhere. The links in the topic "New documentation subproject started" are bad. I use ZeosDBO in Delphi. I have DBGrid connected to DataSet connected to ZQuery connected to ZConnection connected to SQLite3. I need to set cursor in DBGrid to specific record with specific name and date of birth for example. In TTable, there is a function Table1.FindNearest('text'), that allows to do that. But I don't know such function in ZQuery. ZQuery1.FindFirst seems to look for the files ZQuery1.Locate - for the options, ZQuery1.Lookup - I don't get what it is, I don't have the manual.
Last edited by Plavozont on 28.04.2012, 16:52, edited 1 time in total.
It's same as regular VCL TQuery.Locate().
Try searching in Delphi help...
http://docwiki.embarcadero.com/Librarie ... Set.Locate
Try searching in Delphi help...
http://docwiki.embarcadero.com/Librarie ... Set.Locate
I would like some manual on ZeosDBO/ZeosLib please.
I have found some sort of a way to do what I want, I use ZQuery1.filter. But I have trobles filtering date field. In ZQuery1.SQL I have something like this:
SELECT ...( (case birth_d when 1 then '--' else strftime("%d", birth_date) end) || '.' || (case birth_m when 1 then '--' else strftime('%m', birth_date) end) || '.' || (case birth_y when 1 then '----' else strftime('%Y', birth_date) end) ) as birth_date...
Then I filter:
filt:='birth_date = "1981-07-23";//like this
filt:='birth_date = "23.07.1981";//or like this
Form1.ZQuery1.Filter:=filt;
Form1.ZQuery1.Filtered:=true;
My DBGrid fills with nothing.
When I filter like this:
filt:='birth_date = "--.--.1981";
Zeos says "--.--.1981" - is a bad date.
According to SELECT statement its not a date its a concatinated string.
I have found some sort of a way to do what I want, I use ZQuery1.filter. But I have trobles filtering date field. In ZQuery1.SQL I have something like this:
SELECT ...( (case birth_d when 1 then '--' else strftime("%d", birth_date) end) || '.' || (case birth_m when 1 then '--' else strftime('%m', birth_date) end) || '.' || (case birth_y when 1 then '----' else strftime('%Y', birth_date) end) ) as birth_date...
Then I filter:
filt:='birth_date = "1981-07-23";//like this
filt:='birth_date = "23.07.1981";//or like this
Form1.ZQuery1.Filter:=filt;
Form1.ZQuery1.Filtered:=true;
My DBGrid fills with nothing.
When I filter like this:
filt:='birth_date = "--.--.1981";
Zeos says "--.--.1981" - is a bad date.
According to SELECT statement its not a date its a concatinated string.
I figured that when filter looks like this:
filt:='birth_date = "--.--.1981";
Zeos says "--.--.1981" - is a bad date.
But when it looks like this:
filt:='birth_date = "--;--;1981";
Or even like this:
filt:='birth_date = "Simon Smith";
It says nothing, but still I can't filter anything even with dates that look normaly.
P.S. My "Name" field filters just fine.
P.S.S. Manual says something about asterisk in filter, it doesn't work, not for me, not for birth_date, not for the name.
filt:='birth_date = "--.--.1981";
Zeos says "--.--.1981" - is a bad date.
But when it looks like this:
filt:='birth_date = "--;--;1981";
Or even like this:
filt:='birth_date = "Simon Smith";
It says nothing, but still I can't filter anything even with dates that look normaly.
P.S. My "Name" field filters just fine.
P.S.S. Manual says something about asterisk in filter, it doesn't work, not for me, not for birth_date, not for the name.
Last edited by Plavozont on 27.04.2012, 08:27, edited 1 time in total.