Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Clonning a connection
Message
De
18/04/2007 15:30:36
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
 
À
16/04/2007 14:50:23
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01215928
Message ID:
01217452
Vues:
14
>>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)?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform