>>How about creating a new connection and pass the same connection string to the constructor?
>>
>>
>>SqlConnection NewCon = new SqlConnection(globalSqlConnection.ConnectionString);
>>
>>Dim NewCon as New SqlConnection(globalSqlConnection.ConnectionString)
>>
>
>I believe this is what I had before I made the change. I had something like this:
>
>
> oCommand.Connection = oApp.aConnection(nConnectionString, 2)
>
>
>But, assigning the application connection to oCommand.Connection was making it to be used globally and collisions were presents. So, I change to this:
>
>
> ' Get the proper definition as per the current scope
> If oProcess Is Nothing Then
> oCommand.Connection = oApp.aConnection(nConnectionString, 2)
> Else
> oCommand.Connection = oProcess.aConnection(nConnectionString, 2)
> End If
>
>
>Where oProcess is the connection object which is created at every hit so no collision can occur.
>
>Or, is there a way for me to go back to the old approach and use your approach so I will avoid creating a connection object at every hit? Because, doing that slows down the process by 0.03 second.
Michel,
There's something strange about this. A reference to a connection _is_ the connection. So one reference is the same as another as far as data access goes. Maybe the null reference exception is being caused by unanticipated execution flow rather than anything specifically to do with the connection objects.
When the exception occurs, which object is null (connection or transaction)?