SqLite3 lazarus / 16-Databases ---------------------------------------------------------------------- nugax · 2018-02-12 15:11 Ok, So I execute and pull in data from a "SELECT * FROM table" statement in pascal. How do I simply loop through each row? I am successfully pulling the data, but cant figure out how to get to next row once done with this one! I know easy, and I have searched google and found so much info none of which was helpful. I dont think you need my code just to tell me how to go to each row. Im sure its a while/for/ or some type of loop but I know someone knows off the top of their head. Thanks! ---------------------------------------------------------------------- valdir.marcos · 2018-02-12 15:28 http://wiki.lazarus.freepascal.org/SqlDBHowto Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Program ShowData; {$mode objfpc} {$ifdef mswindows}{$apptype console}{$endif}uses  DB, Sysutils, sqldb, sqlite3conn; var  AConnection  : TSQLConnection;  ATransaction : TSQLTransaction;  Query        : TSQLQuery; begin  AConnection := TSQLite3Connection.Create(nil);  ATransaction := TSQLTransaction.Create(AConnection);  AConnection.Transaction := ATransaction;  AConnection.DatabaseName := 'test_dbase';  Query := TSQLQuery.Create(nil);  Query.SQL.Text := 'select * from tblNames';  Query.Database := AConnection;  Query.Open;  while not Query.Eof do  begin    Writeln('ID: ', Query.FieldByName('ID').AsInteger, 'Name: ' +                                  Query.FieldByName('Name').AsString);    Query.Next;  end;  Query.Close;  AConnection.Close;  Query.Free;  ATransaction.Free;  AConnection.Free;end. ---------------------------------------------------------------------- cdbc · 2018-02-12 15:34 Hi nugax Well you've got data in your Dataset with -> "SELECT * FROM table" , then you do something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Dataset.First;  // <- importantwhile not Dataset.EOF do try  // fetch your data here and process them  Dataset.next; // will move cursor to the next row !!! important or you will have an endless loop on your hands ;-)except ...end; ... or take look at "TDataset" in the source Hth - regards Benny ---------------------------------------------------------------------- nugax · 2018-02-12 15:40 Got it. Thanks guys! ---------------------------------------------------------------------- nugax · 2018-02-12 17:33 Does query.recordcount return the number of records from the query? I have 12 records, confirmed in the sqlite db, SELECT * FROM table; yet, query.recordcount only returns 10. Quote from: cdbc on February 12, 2018, 04:34:45 pmHi nugax Well you've got data in your Dataset with -> "SELECT * FROM table" , then you do something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Dataset.First;  // <- importantwhile not Dataset.EOF do try  // fetch your data here and process them  Dataset.next; // will move cursor to the next row !!! important or you will have an endless loop on your hands ;-)except ...end; ... or take look at "TDataset" in the source Hth - regards Benny ---------------------------------------------------------------------- mangakissa · 2018-02-12 17:48 Because property  packetrecords is set to 10. Set the value to -1 and al records in selected query are count.