* * *

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

rickielynn

  • New member
  • *
  • Posts: 17
[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 »

GetMem

  • Hero Member
  • *****
  • Posts: 2926
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

  • New member
  • *
  • Posts: 48
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.
Lazarus 1.8.2 / FPC 3.0.4 / Windows 8.1 64-bit

rickielynn

  • New member
  • *
  • Posts: 17
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

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus