Re: CoInitialize failure with many processes

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Brian,

I would of loved to have provided that information earlier, but I did not
write this code and I'm learning both this part of the code and COM at the
same time. The original authors no longer work here. Prior to today, I
couldn't of told you what ADO was, let alone how it is used.

Your suggestion regarding creation of a COM+ DLL installed into Component
Services with pooling sounds promising. I'll will dig in that direction.

Thanks for your help,
Dan

"Brian Muth" wrote:


"Dan" <Dan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BE92EC61-A5B2-4D2F-845F-BCEC7BE6D8B3@xxxxxxxxxxxxxxxx
Brian,

As I continue to dig through this code, it appears that it is using COM to
directly communicate with the SQL server. I'm learning as I go here.

Prior to calling CoInitialize(NULL), there is nothing done of interest.
(e.g. Setting thread priority, parsing command line arguments, etc) After
the CoInitialize, the connection is made using a msado15.tlh file and a
_connection object (apparently an ADO object, or ActiveX Data Object).
CreateInstance is called on a _ConnectionPtr object, then Open is called
on
this object with the following connection string:

"Provider=sqloledb;Server=%*.*S%S%*.*S;Database=%*.*S%SSystem;Trusted_Connection=Yes;"

The resulting object is returned as a _variant_t object casted from an
(IUnknown*) pointer. This variant object is passed into a _RecordsetPtr
object's Open function along with an SQL statement casted as a _variant_t
object as well.

Regarding the Performance Monitor, I haven't seen anything out of the
ordinary. What performance objects and counters should I be looking at?


This was a very helpful post. I wish in fact that you provided this very
relevant information at the beginning.

I'm surmising that you have a simple application that is accessing SQL
Server using classic ADO. This is a simple client-server type of
relationship. Scaling is definitely going to be an issue here, since SQL
Server can only handle so many connections at one time. Double-check the
code to ensure that any ADO connection is closed explicitly. This is
especially important if you are opening and closing connections more than
once, as leaving out the call to Close() will accelerate exhaustion of SQL
resources.

You can use the SQL Server Profiler to examine the number of connections
while you start launching. This is an extremely important tool for you, so
if you are unfamiliar with it, now is the time to do your research and learn
how to use it properly. Also, use your favourite search engine and enter
"ADO SQL Connection Pooling" and you will find lots of hits relevant to this
problem.

You will need to fully leverage SQL Server connection pooling. There are
probably several ways of tackling it but I would recommend that a very
simple COM DLL be written that calls the SQL Server on behalf of any client
process. Then install this COM DLL into Component Services to change it to a
COM+ application. This will enable connection pooling, and you should be
able to easily launch hundreds of processes without running into the problem
you are currently facing. Your application is no longer a client-server
architecture, but now an n-tier architecture, and will scale much, much
better.

This simple COM+ DLL could be written in VB6, although C++ of course could
also be used.

Good luck with your project.

Regards,

Brian



.



Relevant Pages

  • Re: SQL Resets
    ... If it were SQL that was falling short, ... The default backlog for SQL Server is 5. ... System.InvalidOperationException: Internal connection fatal error. ... From time to time, under heavy loads, we are getting resets at ...
    (microsoft.public.sqlserver.connect)
  • Re: provider: Named Pipes Provider, error: 40 - Could not open a c
    ... I have tried connecting to Sql Management Studio and it worked pretty much ... An error has occurred while establishing a connection to the server. ... under the default settings SQL Server does not allow remote connections. ... I have a sql server install / database on the web server. ...
    (microsoft.public.sqlserver.connect)
  • RE: Logging in in background
    ... wold take all kinds of modifictions as I'd need to be checking that each SQL ... my database and all have connection strings associated with them. ... I suspect that there is also an issue on the SQL Server side as I keep ...
    (microsoft.public.access.modulesdaovba)
  • Re: Sql Server 2000 slow
    ... If I close the connection (moving the Open/Close ... ADO) and the dll gives twice the performance. ... > Are there any known performance issues with .NET accessing Sql Server ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Pessimistic locking with approles.
    ... The "fix" is to disable connection pooling in ADO in the connection ... security or SQLS security, and it has nothing whatsoever to do with ... SQL Application Role Errors with OLE DB Resource Pooling ...
    (microsoft.public.sqlserver.security)