title: How to enable OLEDB resource pooling in a Delphi 7 app
body: <p>What needs to be done to enable pooling in a Delphi 7 app?  My connection string is:</p>
  
  <p>Provider=SQLOLEDB.1;Initial Catalog=%s;Data Source=%s;Password=%s;User ID=%s;OLE Db Services=-1</p>
  
  <p>I can tell that connection pooling is not being achieved by looking at the SQLServer:GeneralStatistics UserConnections performance counter - it fluctuates wildly when my application runs.  With connection pooling I'd expect it to achieve a steady state.  Also, I see that Logins/sec and Logouts/sec counters are both very high - if connection pooling were used Logouts/sec would be at or near zero.</p>
  
  <p>In searching I found this article on resource pooling:</p>
  
  <p><a href="http://www.ddj.com/database/184416942" rel="nofollow noreferrer">http://www.ddj.com/database/184416942</a></p>
  
  <p>It suggests that "If you are working at the OLEDB SDK (or COM) level using ATL, you have to write some more code" (aside from adding OLE Db Services=-1 to the connection string) to get connection pooling:</p>
  
  <p>CDataSource db;
  CDBPropSet  dbinit(DBPROPSET_DBINIT);</p>
  
  <p>dbinit.AddProperty(DBPROP_AUTH_USERID, "MyName);
  dbinit.AddProperty(DBPROP_INIT_DATASOURCE, "MyServer);
  dbinit.AddProperty(DBPROP_INIT_CATALOG, "MyDb );
  dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
  dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);
  dbinit.AddProperty(DBPROP_INIT_OLEDBSERVICES, (long)DBPROPVAL_OS_ENABLEALL);
  HRESULT hr = db.OpenWithServiceComponents(_T("sqloledb"), &amp;dbinit);</p>
  
  <p>Unfortunately that code is Greek to me and I'm not sure how to translate that to Delphi (or if its even necessary).</p>
  
  <p>I'm also careful not to change the connection string at all.  Any suggestions on what else I might need to do to enable resource pooling?</p>