#1 2016-11-04 10:22:21

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 507

Using Step(True) with MSSQL Twice Throws Exception

Hi AB we swithed our Database from MySQL to MS-SQL.

In our Code we use Something like:


  procedure WorkWithRows(const ARows : ISQLDBRows);
  var
    LSeekFirst : boolean;
  begin
    LSeekFirst := True;
    while ARows.Step(LSeekFirst) do begin
      LSeekFirst := False;
....
    end;
 
  end;

var
  LSQLDBRows : ISQLDBRows;
begin
...
  Database := TOleDBMSSQL2012ConnectionProperties.Create ....

  LSQLDBRows := Database.ExecuteInlined('select something from table', True);

  WorkwithRows(LSQLDBRows);

  WorkwithRows(LSQLDBRows);  <- Exception because ISQLDBRows cannot not MoveFirst !

  WorkwithRows(LSQLDBRows);
...
end;

It seems that the OleDB Cursor is not the right type. I don't know where to modify this.


Rad Studio 12.1 Santorini

Offline

#2 2016-11-04 12:10:16

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,549
Website

Re: Using Step(True) with MSSQL Twice Throws Exception

See this topic
In short - fetch all data in memory first using a ExecutePreparedAndFetchAllAsJSON

Offline

#3 2016-11-08 16:44:02

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 507

Re: Using Step(True) with MSSQL Twice Throws Exception

ty we used TSQLDBUniDACConnectionProperties instead and it feels to work.


Rad Studio 12.1 Santorini

Offline

Board footer

Powered by FluxBB