i want to manage connection pooling using C++ code, below is the code i
am using so can any body tell me if this code is correct or not ? if
not plz send me a snap shot !!!
if the code is correct i am having some queries:
1) my connection string is correct or not ? (because i am
using pooling paramerter also)
In my code it is not throwing any exception & working
properly
2) in connection string i am using pooling = true/false
but it dont show any difference in
true case or in Flase case. i hope it is using
pooling concept implicitly by default
3) m_pConnection->Close(); is not loosing the connection
i am seeing in the Perfmon.msc ->(SQL Server:General
Statistics,User
Connections) but it is not loosing the
connection(graph is not falling).
4) Please suggest me how a connection pool will be cleared
if Connection max size
exceded
I was very confused to Debug and analyze according to theory concepts
so plz some body help.
int main()
{
CoInitialize(NULL);
_ConnectionPtr m_pConnection;
_ConnectionPtr rasheed;
m_pConnection.CreateInstance(__uuidof(Connection));
for(int i = 0; i < 100; i++)
{
try
{
//Connection String and Connection
Creation........
m_pConnection->Open("Provider='SQLOLEDB'; Persist
Security
Info=False;UserID=sa;Password=sa; Data Source=
(local);Initial
Catalog='databasename';Integrated
Security='SSPI';Min Pool Size=0;Max Pool Size=10;OLE
DB Services= -
1; pooling = true","","",
adConnectUnspecified );
// Doing Some Action...........
//Connection Close........
m_pConnection->Close();
}//End of Try block
catch(_com_error & conn)
{
printf("%s",conn.ErrorMessage);
}//End of Catch block
}//End of loop
CoUninitialize();
return 0;
}
Sincerly,
Rasheed
I likely don't understand the whole problem. But...
1) You can't "control" connection pooling. A connection either participates
in the pool or it does not.
2) If 'A Connection' participates in an ADO Pool - then it is up to the
Provider and Database 'engine' to work out the details. You have no input
into the conversation.
3) If 'A Connection' doesn't participate in a pool. You may suggest that it
should open and close - but that doesn't mean it will happen at exactly that
moment - if the provider/database are busy negotating other issues.
4) You might need to use "OLE DB Service=-4" (minus 4) instead of
"Pooling=False" to single THAT connection is not to participate.
hth
-ralph
hth
-ralph