public void SetActive(ConnectionParameters connectionParameters) { ActiveConnectionParametersName = connectionParameters.Name; }
public static DbCommand GetCommand(string cmdText, ConnectionParameters connectionParameters) { return GetCommand(cmdText, connectionParameters.Name); }
public static DbConnection GetConnection(ConnectionParameters connectionParameters) { return GetConnection(connectionParameters.Name); }
public static void SetConnection(ConnectionParameters connectionParameters) { // When setting the connection, the default connection name is set if necessary // Can only be set once. // This is to allow an application that doesn't care about the connection name (only uses one connection at a time) // to work well. if (string.IsNullOrEmpty(DefaultConnectionName)) { if (string.IsNullOrEmpty(connectionParameters.Name)) { DefaultConnectionName = "Default_Connection"; } else { DefaultConnectionName = connectionParameters.Name; } } if (string.IsNullOrEmpty(connectionParameters.Name)) { connectionParameters.Name = DefaultConnectionName; } bool connectionExists = false; if (connectionParametersDict.ContainsKey(connectionParameters.Name)) { // Connection with that name already exists // Check if parameters are the same and dispose current if so if (connectionParameters.Equals(connectionParametersDict[connectionParameters.Name])) { connectionExists = true; } else { connectionParametersDict.Remove(connectionParameters.Name); } } if (!connectionExists) { connectionParametersDict.Add(connectionParameters.Name, connectionParameters); CreateConnection(connectionParameters.Name); } }
public static void SetConnection(string server, string database, string user, string password, DbFamily dbFamily, string connectionName) { ConnectionParameters parameters = new ConnectionParameters(server, database, user, password, dbFamily); parameters.Name = connectionName; SetConnection(parameters); }
public static void RemoveConnection(ConnectionParameters connectionParameters) { RemoveConnection(connectionParameters.Name); }
/// <summary> /// Returns a string with information about the DB connection. /// The string will be empty if there's no connection. /// </summary> /// <param name="connectionParameters"></param> /// <returns></returns> public static string GetConnectionInfo(ConnectionParameters connectionParameters) { return GetConnectionInfo(connectionParameters.Name); }
/// <summary> /// Returns true if this object is equal to the one passed in. /// </summary> /// <param name="obj"></param> /// <returns></returns> public bool Equals(ConnectionParameters obj) { // Does not compare Name or Description b/c those are just for information // and have no effect on the connection return object.Equals(Server, obj.Server) && object.Equals(Database, obj.Database) && object.Equals(User, obj.User) && object.Equals(Password, obj.Password) && object.Equals(DbFamily, obj.DbFamily); }