Problem with auto new connection

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Romano
Posts: 41
Joined: Tue 10 Feb 2009 11:21

Post by Romano » Mon 14 Sep 2009 12:37

Hi,
I think that it is misunderstanding over this topic.
I write about ResultSets all the time.
DisableMultipleResults works with FIMultipleResults, not with ResultSets.

The same situation as in my last reply is in this code:

Code: Select all

var
  MyQuery: TMSQuery;

with MyQyery do
begin
  SQL.Add(
    'PRINT ''xxx'''#13+
    'SELECT 1');

  Options.DisableMultiplyResults := True;
  Open; // error
end; 
PRINT 'xxx' doesn't return any ResultSets and ResultSet from SELECT 1 is not readed.

What I need is discard all ResultSets after reading the first ResultSet. I cannot use DisableMultipleResults for it.

My question: Can I use this code?

Code: Select all

type 
  TMyQuery = class(TMSQuery)
  public
    procedure Execute; override;
  end;

procedure TMyQuery.Execute;
begin
  inherited;

  if HasNextResultSet then
  begin
    // free all next results, so also ResultSets
    if FIRecordSet  nil then
      with TOLEDBCommand(FIRecordSet.GetCommand) do
      begin
        ClearIMultipleResults;
        ClearIUnknownNext;
      end;
  end;
end;
One hint at the end :) :
You have procedure ClearIUnknownNext; but you don't use it.
Instead of it you are using FIUnknownNext := nil;

Thanks
Roman

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 15 Sep 2009 06:54

Yes, you can use this code, it is correct.

Post Reply