This is a known issue with SQL and ODBC.  The combination only allows one
active (updatable?) query per connection.  A query is active until all rows
have been retrieved from the server.  This is why each TTable establishes a
new connection.

Solutions/workarounds

1       When opening queries, use a FetchAll (or Last) if possible to retrieve all
rows.
On my queries I have the folowing event handler:

procedure TdmodShared.sqlStringFieldByRefAfterOpen(DataSet: TDataSet);
begin
  TQuery(DataSet).FetchAll;
end;

2       Open a new connection (using TSession or TDatabase, can't remmeber which)
for persistant offender queries.

3       Use CachedUpdates (not sure if this helps or not)

I was going to write a query descendant which would open a new connection
for any live query.  However use of 1 and 3 has quelled the problem.

Regards


Sean

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of [EMAIL PROTECTED]
> Sent: Tuesday, 15 June 1999 15:08
> To: Multiple recipients of list delphi
> Subject: [DUG]: "Connection is busy with results for another hstmt"
>
>
> Hi all,
>
> I am currently struggling to get past the following error message
> when firing off several large queries to SQL Server 7.0:
>
> "Connection is busy with results for another hstmt"
> I am connecting using ODBC, Delphi 4 C/S on WinNT 4.0. A quick
> search on Developers.href reveals many others who have
> encountered the same problem, but no practical solutions. One
> approach is to use server side cursors, but we are executing
> complex queries which do not meet the criteria for a server
> cursor (ie multiple SELECTs in a statement).
> Any suggestions most gratefully accepted.
> On a related note, we have found that connecting to SQL Server 7
> via the BDE with the native driver supplied with D4 C/S is
> considerably (as much as 250%) slower than accessing via the ODBC
> driver. Anybody noticing similar results, or have we missed
> something major??
>
> Cheers,
> James.
>
>
> ------------------------------------------------------------------
> ---------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to