Restricted connection number - how?

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 1
Joined: Wed 09 Mar 2011 12:11

Restricted connection number - how?

Post by tolyas » Wed 09 Mar 2011 12:39

Your components looks good, and I plan buy this packet after fulfilling additional tests.
But now I have one problem.

It is necessary to manage and restrict the number of connections for MS SQL Server.

I used early TAdoConnection, which bases upon MS OLE DB.
There is information in MSDN
In OLE DB resource pooling, the following formula determines the number of pools (where N is the number of pools, P is the number of processors, and C is the number of distinct sets of connection attributes on the system):

N = (P + 1) * C

That is - if my machine has 2 CPU then I can reach only 3 active TAdoQuery, connected for ONE TAdoConnection (if number of active MSSQL connections restricted of 1). If I add 4'th active query, then number of connections automatically become 2.

The question is - may I increase this amount of active queries with your components? For examle, may I use 10 active TMSQuery,connected to one TMSConnection, if number of active MSSQL connections = 1?
How can I do it?

Thank you


Post by AndreyZ » Thu 10 Mar 2011 10:19


You can freely use several active queries through one connection. Here is an example of using one connection with one hundred active queries:

Code: Select all

const n = 100;
  qq: array[1..n] of TMSQuery;
  i: integer;
    for i := 1 to n do begin
      qq[i] := TMSQuery.Create(nil);
      qq[i].Connection := MSConnection;
      qq[i].SQL.Text := 'select * from table';
    for i := 1 to n do
Connection pooling doesn't mean that you cannot have several active queries through one connection. The formula you wrote defines the number of available pools for your application. Connection pooling enables an application to use a connection from a pool of connections that do not need to be reestablished for each use. Once a connection has been created and placed in a pool, an application can reuse that connection without performing complete connection process. SQL Server Data Access Components provide connection pooling by their own. You can read about it in the "Using Connection Pooling" topic of the SDAC documentation.

Post Reply