I have derived my own component from TAdoQuery in Delphi. I have overridden the DoAfterPost procedure; and in this code I create another query for the purpose of fetching the primary key associated with an inserted record (i.e. SELECT @@IDENTITY for SqlServer, SELECT LAST_INSERT_ID() for MySql, etc).
In the past I always used TAdoConnection for database connectivity. And in the "subquery" call made within DoAfterPost there was no problem because it was the SAME Session (these queries to retrieve last inserted primary keys assume a persistent database connection).
I recently made an option where instead of using a TAdoConnection connection, I am instead setting the ConnectionString property (for multi-thrading purposes). But this creates a problem because the spawned subquery does not use the same session as the main query. Hence it does not return the primary key value.
My question is, does TAdoQuery have any Connection property if the ConnectionString is used? I could then daisychain this connection/session to my subquery. Or is the only way to accomplish this via a TAdoConnection?