Ali
Ali

Reputation: 3

SqlConnection already open in case of concurrent access to same ASP.Net page

I have a strange problem in my ASP.Net 3.5 application. When multiple users try to access the same page (which has some long running methods), the application crashes at a point where it tries to open a connection to the database (a static method inside a static class). It appears that the connection is already open. However, this does not happen when there is only one user using the application. What I cannot understand is that how do actions of one user affect the other in a web application? I double checked that all my open connections are being closed after performing their operation by appending a line of text to a text file whenever a connection is opened or closed. The number of opened and closed connections was equal. Also, the connections are opened and closed from one place only, where the close method is inside a Finally() block. Has anybody experienced such behaviour before? Your replies will be most appreciated.

Thanks,

Ali

Upvotes: 0

Views: 348

Answers (1)

Keith
Keith

Reputation: 5381

Is your SqlConnection object defined as static? This would cause all sessions to share a single connection object, and would cause the behavior you're experiencing.

Upvotes: 4

Related Questions