Recent

Author Topic: [Solved] Start at beginning of dataset?  (Read 1823 times)

rickielynn

  • New Member
  • *
  • Posts: 18
[Solved] Start at beginning of dataset?
« on: January 03, 2018, 06:06:52 am »
I'm using SQLite with Lazarus to select a subset of a database using the SELECT statement.  Then I want to do something with that dataset by using a While NOT SQLQuery.EOF DO followed by statements.

My question is how can I be sure I'm starting at the beginning of the dataset?  Some of the dataset is not getting affected by the statements after the While NOT...statement.   I'd like to use a SQLQuery.MoveFirst statement before the While Not, but don't see one available.

Thanks,
Rick
« Last Edit: January 03, 2018, 07:57:54 pm by rickielynn »

balazsszekely

  • Guest
Re: Start at beginning of dataset?
« Reply #1 on: January 03, 2018, 06:12:02 am »
Before the while loop insert:
Code: Pascal  [Select][+][-]
  1. SQLQuery.First;

dsiders

  • Hero Member
  • *****
  • Posts: 1052
Re: Start at beginning of dataset?
« Reply #2 on: January 03, 2018, 06:20:08 am »
TSqlquery has the navigation methods inherited from TDataset: First, Next, Prior, and Last.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

rickielynn

  • New Member
  • *
  • Posts: 18
Re: Start at beginning of dataset?
« Reply #3 on: January 03, 2018, 07:57:20 pm »
I think the problem was I was deleting a record inside the While Not .EOF loop and that was somehow causing a record to be missed.  I changed the While Not .EOF to a FOR...DO loop then jump out of the loop if SQLQyery.Recordset=0 and it seems to work.

Thanks,
Rick

 

TinyPortal © 2005-2018