public List <RouteInfo> SelectRoutes(out string errorMessage) { errorMessage = string.Empty; List <RouteInfo> list = new List <RouteInfo>(); string sql = SqlScripts.SelectRoutesScript(); { SqlDataReader reader = null; SqlConnection connection = new SqlConnection(ConnectionString); SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.Text; command.CommandText = sql; try { connection.Open(); reader = command.ExecuteReader(); while (reader.Read()) { RouteInfo route = new RouteInfo() { Name = reader.IsDBNull("remote_service_name") ? string.Empty : reader.GetString("remote_service_name"), Broker = reader.IsDBNull("broker_instance") ? string.Empty : reader.GetString("broker_instance"), Address = reader.IsDBNull("address") ? string.Empty : reader.GetString("address") }; route.Name = string.IsNullOrWhiteSpace(route.Name) ? string.Empty : GetQueueName(route.Name); list.Add(route); } } catch (Exception error) { errorMessage = ExceptionHelper.GetErrorText(error); } finally { if (reader != null) { if (reader.HasRows) { command.Cancel(); } reader.Dispose(); } if (command != null) { command.Dispose(); } if (connection != null) { connection.Dispose(); } } } return(list); }