/// <summary>Create a connection object to the database</summary> /// <returns>SQL server Connection Object.</returns> protected sealed override IDbConnection CreateConnection() { string conString; if (ConnectionString == string.Empty) { if (mServerName == null || mServerName == string.Empty) { throw new BadUsageException("The ServerName can't be null or empty."); } if (mDatabaseName == null || mDatabaseName == string.Empty) { throw new BadUsageException("The DatabaseName can't be null or empty."); } conString = DataBaseHelper.SqlConnectionString(ServerName, DatabaseName, UserName, UserPass); } else { conString = ConnectionString; } return(new SqlConnection(conString)); }
/// <summary> /// Create a new instance of the SqlServerStorage based on the record /// type provided (uses SqlServer auth) /// </summary> /// <param name="recordType">The type of the record class.</param> /// <param name="server">The server name or IP of the sqlserver</param> /// <param name="database">The database name into the server.</param> /// <param name="user">The SQL username to login into the server.</param> /// <param name="pass">The pass of the SQL username to login into the server.</param> public SqlServerStorage(Type recordType, string server, string database, string user, string pass) : this(recordType, DataBaseHelper.SqlConnectionString(server, database, user, pass)) { mServerName = server; mDatabaseName = database; mUserName = user; mUserPass = pass; }