Page 1 of 1

ADO: Open RecordSet for each SelectSQL

Posted: 15.06.2009, 15:55
by LOTAS
Hi. I need very fast help!!

During some tests I did because of problems with transactions, I encountered that the ado-component opens a new session to the ms sql-db every time a select-statement is done.

Line 177 in ZDbcAdoStatement.pas

Code: Select all

if IsSelect(SQL) then
    begin
      AdoRecordSet := CoRecordSet.Create;
      AdoRecordSet.MaxRecords := MaxRows;
      AdoRecordSet.Open(SQL, (Connection as IZAdoConnection).GetAdoConnection,
        adOpenStatic, adLockOptimistic, adAsyncFetch);
    end
    else
      AdoRecordSet := (Connection as IZAdoConnection).GetAdoConnection.Execute(SQL, RC, adExecuteNoRecords);
Is this really needed? And most of all, WHY is it done?

Our problem is, that we want to set the lock_timeout, and as this is used for each session seperated, we have to set it manually befor each select sql.

That's not really as it should be. As we ported some programs to ms sql because a customer wants it, we are in a bit of hurry and don't have so much time to test and rebuild our program (till now we used BDE and Sybase-DB where everything worked fine).

Our ZEOSlib Version is 6.6.1 beta

Posted: 26.06.2009, 13:24
by LOTAS
Noone who have any suggestions? Unfortunately there is no comment in code.

Posted: 08.07.2009, 21:16
by mdaems
Hi, Are you sure this opens a new session or is it just opening a new resultset?
I'm not an ADO user, so I can't investigate myself. Just looking at it, seems to reuse the already existing connection/session. Am I wrong?

Mark

Posted: 10.07.2009, 07:23
by LOTAS
Hi.
As on the sessioncounter, visible on the ms sql db it opens a new session.

This was what was so astonishing.

It may be, that it's a new resultset and the DB thinks it a new session and therefore handle it as one, that I don't know. Nevertheless the DB genereates a new session id.