Lazarus 0.9.31; FPC 2.4.2; SQLite3 0.4; ZeosLib 7.7.0-dev; Win Vista (64-bit)
I am trying to learn Lazarus/FPC by re-writing an application that I had originally developed in MS-Access and then subsequently re-wrote in Visual Basic. The application utilizes a .mdb back end data file. Having little luck in accessing the .mdb file in Lazarus via ODBC (issues with 64-bit ODBC driver), I decided to convert the .mdb data file to .db3 (SQLite-3). Upon reading several posts on the this forum, I decided to go with ZeosLib for data access. So far, I've successfully created a TDBGrid and populated it via a TZConnection -> TZReadOnlyQuery -> TDatasource. So, now comes the "easy" part...
I need to retrieve a couple of fields from a record in the query to populate TEdit fields on my form. For the life of me I haven't been able to find any documentation or program examples that retrieve a record in code. Based on my past experience, I would expect the scenario to go something like this:
Modify the existing query, if needed, with a filter or write an SQL statement for the query.
Execute the query.
Loop through the query with something like:
_____.Find First
If _____.Found then
While not _____.EOF do
begin
Something := _____.FieldByName('myfield');
If Something = {my criteria} then
begin
.....
myTEdit.text := Something;
.....
end;
_____.Next;
end;
or some similar code.
My problem primarily is what should _____ be? Does _____ reference my query or the datasource? What is the correct syntax? Is there a better/easier way to re3trieve the field contents?
I appreciate some guidance. Also, can anyone point me to a reference (on-line or in print) that would address this type of issue?
Thanks.