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

Bo Berglund bo.berglund at gmail.com
Tue Jan 25 22:30:35 CET 2011


On Tue, 25 Jan 2011 21:45:31 +0100 (CET), Michael Van Canneyt
<michael at freepascal.org> wrote:

>
>
>On Tue, 25 Jan 2011, José Mejuto wrote:
>
>> Hello Lazarus-List,
>>
>> Sunday, January 23, 2011, 12:06:12 PM, you wrote:
>>
>> MVC> Attached is a possible patch. I don't have MS-SQL (doesn't
>> MVC> run on Linux) so I can't test.
>> MVC> Please apply it to packages/fcl-db/src/sqldb/sqldb.pp and
>> MVC> report whether this helped you
>> MVC> solve your problem. If so, I will commit it to SVN.
>>
>> I think this piece of code is a problem for your patch (last line):
>>
>> function TCustomSQLQuery.Fetch : boolean;
>> begin
>>  if not (Fcursor.FStatementType in [stSelect,stExecProcedure]) then
>>    Exit;
>>
>>  if not FIsEof then FIsEOF := not TSQLConnection(Database).Fetch(Fcursor);
>>  Result := not FIsEOF;
>>  // A stored procedure is always at EOF after its first fetch
>>  if FCursor.FStatementType = stExecProcedure then FIsEOF := True;
>> end;
>
>Aha....
>
>This is indeed the problem. However, under Firebird, it is correct. 
>An Execute will return only the first values.
>
>To Bo: Please comment the above line, and see if that fixes your problem.
>Please report back here on your findings. 
>I will talk to Joost and  what to do with this.
>
>Michael.

Thanks a bunch!
I commented out the last line in the function:

  //if FCursor.FStatementType = stExecProcedure then FIsEOF := True;

And this solved the problem, now the EXEC call returns the 4 expected
records! :)

Great! Now I can proceed to test my other database functionality with
lazarus. :-)



-- 
Bo Berglund
Developer in Sweden





More information about the Lazarus mailing list