Connecting to SQL Server

  • I saw an example where a management (SMO) connection was created using a SQLClient.SqlConnection.

    Something like this;

    Dim sqlConn As SqlClient.SqlConnection = New SqlClient.SqlConnection(connString)

    Dim severConn As ServerConnection = New ServerConnection(sqlConn)

    server = New Server(severConn)

    My question is why does this method even exist?

    It seems sort of odd to pass a connection to a connection.

     

     

     

     

     

     

     

     

     

     

  • Not sure that this is the case.  But I think that if you pass a connection in parameter, then the smo will NOT create a new connection.  But instead, will use the connection object as a refference.  So instead of 2 connection, you have only one.  This can be a big deal on a busy server.

  • I'll have to test that. I sure can't see any other reason. Thanks.

  • How about not having to use a second variable to remember the connection string... or if you don't have access to the global connection string, but have access to the global connection object (not that this would make any sens at all )?

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply