Re: Best practice to work with multiple DB connections



Thanks for your valuable input. Can you suggest the best one out of your two suggestions?

"Marc Gravell" <marc.gravell@xxxxxxxxx> wrote in message news:uVhAV4BBIHA.1212@xxxxxxxxxxxxxxxxxxxxxxx
0) Since you are on SQL2005, try enabling MARS; this will allow you to call ExecuteScalar -on the same connection - while ExecuteReader is in progress. Sounds too good to be true, but worth a try. Just tweak the connection string to include ";MultipleActiveResultSets=True"

1/2) is not as big an issue as you think, since .NET provides pooling by default. When you Close() a managed connection it (by default) simply goes back into the pool. There is a very good chance (in such an app) that you will get the same actual connection (albeit reset) next time.

Marc


.



Relevant Pages

  • Re: ExecuteScalar closes connection
    ... Yurcus, ... your execute command causes a very high severity exception on the server. ... just check it every time and reopen my connection is nessesary. ... >>> My ExecuteScalar is called in the initialization of my app so all ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: .NET 2.0 und Oracle
    ... einzigen Kunden das ... zwar ein ExecuteScalar auf einer Oracle-Verbindung. ... Die Datenbank ist eine Oracle 10g, der Rechner, auf dem die ... Connection und des SQL-Statements... ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • RE: Need to return a string ( varchar(40) ) from MS-SQLSERVER stored p
    ... must close the connection before the values of output parameters are ... ExecuteNonQuery, ExecuteScalar, etc. and I just can't get the value. ... keeping the empty string in the 4th parameter: ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: ExecuteScalar closes connection
    ... IDBCommand.executescalar is used for fastest retrieval so it can try to close database connection sometimes. ... MCP - ASP.NET ... "Yurcus" wrote: ... > My ExecuteScalar is called in the initialization of my app so all conditions are supposed to be same but sometimes it closes my connection, ...
    (microsoft.public.dotnet.framework.adonet)