Forum > Database

Lazarus and Access-Database

(1/1)

schand99:
Hi,

I have encountered a strange behaviour on Lazarus and MS Access database:
I open a SQL Query which selects a number of records. On the open records I have to check each record for the content of a field. I do this within a repeat ... until loop:

A error raises up when rSSQL.Next points to the last record into rSSQL, just befor rSSQL.EOF is true

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---...rSSQL.open;if not rSSQL.EOF do begin   rSSQL.First;   repeat        ... do something       rSSQL.Next;   until rSSQL.EOF;end; 
If in the same code I first point to the last records and after that I point to the first record, there is no error
Is there anybody else having this problem? Or maybe someone who can explain this strange behavior?

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---...rSSQL.open;if not rSSQL.EOF do begin   rSSQL.Last;           //  <- this one   rSSQL.First;   repeat        ... do something       rSSQL.Next;   until rSSQL.EOF;end; 

Zvoni:
I remember having similiar issues with DAO/ADO on VB6, that i had to move to the last record, and then back to the first, because the EOF and/or recordcount wasn't set properly or something like that.

wp:
The attached demo does the same: it iterates through an Access-based dataset and counts the empty fields, and the error does not occur.

What is different to your case? I could imagine that the fact that the query is attached to a DBGrid in my demo could cause .Last already being called. So, please give more details, or better: upload a simple compilable demo (only pas, lfm, lpi, lpr and database files, all in a common zip, like I did).

Zvoni:
Found something:
http://allenbrowne.com/ser-29.html
Look at Point 5. Sounds like your Problem

Navigation

[0] Message Index

Go to full version