Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Too many connections opened creates a failure
Message
 
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01531136
Message ID:
01531188
Views:
41
>>This should be a little bit better:
>>
>>
>>                        ' Based on the SQL mode
>>                        Select Case nSQLMode
>>
>>                            ' OleDb
>>                            Case 1
>>
>>                                Using loOleDbConnection As New OleDbConnection(cConnectionString)
>>                                    loOleDbConnection.Open()
>>                                    oCommand.Connection = loOleDbConnection
>>                                    nResult = oDataAdapter.SelectCommand.ExecuteNonQuery()
>>                                End Using
>>
>>                                ' SQLClient
>>                            Case 2
>>
>>                                Using loSQLConnection As New SqlConnection(cConnectionString)
>>                                    loSQLConnection.Open()
>>                                    oCommand.Connection = loSQLConnection
>>                                    nResult = oDataAdapter.SelectCommand.ExecuteNonQuery()
>>                                End Using
>>
>>                                ' ODBC
>>                            Case 3
>>
>>                                Using loOdbcConnection As New OdbcConnection(cConnectionString)
>>                                    loOdbcConnection.Open()
>>                                    oCommand.Connection = loOdbcConnection
>>                                    nResult = oDataAdapter.SelectCommand.ExecuteNonQuery()
>>                                End Using
>>
>>                        End Select
>>
Could be shorter :-} :
        Using loOleDbConnection As New OleDbConnection(cConnectionString)
>            loOleDbConnection.Open()
>            oCommand.Connection = loOleDbConnection
>            Select Case nSQLMode
>                ' OleDb
>                Case 1
>                    nResult = oDataAdapter.SelectCommand.ExecuteNonQuery()
>                    ' SQLClient
>                Case 2
>                    nResult = oDataAdapter.SelectCommand.ExecuteNonQuery()
>                    ' ODBC
>                Case 3
>                    nResult = oDataAdapter.SelectCommand.ExecuteNonQuery()
>            End Select
>        End Using
But would not we want to instantiate appropriate connection class depending on the client?
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform