private void OpenAndLogin()
{
// Open the connection and Login
try {
int timeout = _connectionOptions.ConnectTimeout;
_parser = new TdsParser();
timeout = _parser.Connect(_connectionOptions.DataSource,
_connectionOptions.NetworkLibrary,
this,
timeout,
_connectionOptions.Encrypt);
this.Login(timeout);
_fConnectionOpen = true; // mark connection as open
}
catch (Exception e) {
ADP.TraceException(e);
// If the parser was allocated and we failed, then we must have failed on
// either the Connect or Login, either way we should call Disconnect.
// Disconnect can be called if the connection is already closed - becomes
// no-op, so no issues there.
if (_parser != null)
{
_parser.Disconnect();
}
throw e;
}
}