sqlite and zeos lazarus / 16-Databases ---------------------------------------------------------------------- addr3ss · 2015-06-30 11:19 Hello! I want to excute a select query and replace the result with a label caption.I very searched but I did not find a clear way.Can anyone explain it step by step?tnx ---------------------------------------------------------------------- Danyfirex · 2015-07-01 17:49 hi. maybe you must explain better. I think you can use update instead of select. Saludos ---------------------------------------------------------------------- addr3ss · 2015-07-02 08:46 No I want to select some data from DB.I added a Zconnection and setted library and db type and database fields.then added a Zquery and setted my query and connection.but i dont know how to assign query result to a label caption. ---------------------------------------------------------------------- rvk · 2015-07-02 09:12 If your Zconnection and Zquery are set correctly you can do something like this: Code: [Select]  ZConnection1.Connect; // if your ZConnection is not connected yet   ZQuery1.Open;         // if your ZQuery with the select isn't open yet   // this will get the value from field 'your_desired_field' from the first record   Label1.Caption := ZQuery1.FieldByName('your_desired_field').asString;   // if you have multiple records   ZQuery1.Next;   // this will get the value from field 'your_desired_field' from the second record   Label1.Caption := ZQuery1.FieldByName('your_desired_field').asString; This wiki is for SqlDB but it's almost the same for Zeos (especially for reading from a dataset): http://wiki.freepascal.org/SqlDBHowto#How_to_read_data_from_a_table.3F ---------------------------------------------------------------------- jma_sp · 2015-07-02 09:48 Thanks rvk. addr3ss you can also use TDBTEXT in the data controls tab. If connection is OK and also Query Ok it must show some data. You can use tdbnavigator to move across records, equivalent to the explanation of rvk but more friendly visualy. zquery1.next zquery1.prev The advantage of the response of rvk is that you can assign the code directly at your own button for specific functions. More information about this components: http://lazarus-ccr.sourceforge.net/docs/lcl/dbctrls/tdbnavigator.html http://lazarus- ccr.sourceforge.net/docs/lcl/dbctrls/howtousedataawarecontrols.html ---------------------------------------------------------------------- addr3ss · 2015-07-03 10:19 Quote from: rvk on July 02, 2015, 11:12:09 amIf your Zconnection and Zquery are set correctly you can do something like this: Code: [Select]  ZConnection1.Connect; // if your ZConnection is not connected yet   ZQuery1.Open;         // if your ZQuery with the select isn't open yet   // this will get the value from field 'your_desired_field' from the first record   Label1.Caption := ZQuery1.FieldByName('your_desired_field').asString;   // if you have multiple records   ZQuery1.Next;   // this will get the value from field 'your_desired_field' from the second record   Label1.Caption := ZQuery1.FieldByName('your_desired_field').asString; This wiki is for SqlDB but it's almost the same for Zeos (especially for reading from a dataset): http://wiki.freepascal.org/SqlDBHowto#How_to_read_data_from_a_table.3F tnx worked.