public void CreatePublicEndpoint(string name, int port) { if (string.IsNullOrWhiteSpace(CurrentServer)) { throw new InvalidOperationException(ERROR_SERVER_IS_NOT_DEFINED); } { /* start of limited scope */ SqlConnection connection = new SqlConnection(ConnectionString); SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.Text; command.CommandText = SqlScripts.CreatePublicEndpointScript(name, port); try { connection.Open(); int result = command.ExecuteNonQuery(); } catch (Exception error) { // TODO: log error _ = error.Message; throw; } finally { if (command != null) { command.Dispose(); } if (connection != null) { connection.Dispose(); } } } /* end of limited scope */ }