Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Clonning a connection
Message
From
18/04/2007 15:30:36
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
16/04/2007 14:50:23
General information
Forum:
ASP.NET
Category:
Databases
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01215928
Message ID:
01217452
Views:
15
>>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)?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform