[Lazarus] Accessing MS SQLServer database from Lazarus/FPC?

Bo Berglund bo.berglund at gmail.com
Mon Jan 24 21:06:31 CET 2011


On Mon, 24 Jan 2011 19:15:13 +0100, "Dipl. Phys. Jörg Schläger"
<js at jsdevelop.de> wrote:

>>
>> Thanks, this was the simple way I have been looking for!
>> Now that I did that the patch activated and I could see that it no
>> longer barfs at the EXEC verb.
>> Still only returns one record out of 4, though.
>
>is it possible for you to do something like this ?>
>
>
>ii := 0;
>Query1.open;
>while not Query1.eof do
>begin
>iii := ii + 1;
>Query1.next;
>end;
>
>then check ii.
>
>In Delphi the behavour of Query1.recordcount with ODBC and MSsql is mystic
>

The actual code I use is this:

      query.Open;
      S := '';
      while not query.EOF do
      begin
        S := S + query.FieldByName('AppNo').AsString + ' - ' +
             query.FieldByName('AppInfo').AsString + #13#10;
        query.Next;
      end;

After the Open call the while loop is entered and the query.Next
statement causes the query.EOF flag to be set so the loop exits.
This is what I interpreted as caused by the Open method interpreting
the return as having only one record.

As an experiment I added a line as follows after the query.Open
statement:
      i := query.RecordCount;

But this only affirms the fact that the recordset handled by the query
only contains a single record, i = 1.


-- 
Bo Berglund
Developer in Sweden





More information about the Lazarus mailing list