/// <summary> /// Build the connection string /// </summary> /// <param name="nopConnectionString">Connection string info</param> /// <returns>Connection string</returns> public virtual string BuildConnectionString(IBopConnectionStringInfo nopConnectionString) { if (nopConnectionString is null) { throw new ArgumentNullException(nameof(nopConnectionString)); } var builder = new SqlConnectionStringBuilder { DataSource = nopConnectionString.ServerName, InitialCatalog = nopConnectionString.DatabaseName, PersistSecurityInfo = false, IntegratedSecurity = nopConnectionString.IntegratedSecurity }; if (!nopConnectionString.IntegratedSecurity) { builder.UserID = nopConnectionString.Username; builder.Password = nopConnectionString.Password; } return(builder.ConnectionString); }
/// <summary> /// Build the connection string /// </summary> /// <param name="nopConnectionString">Connection string info</param> /// <returns>Connection string</returns> public virtual string BuildConnectionString(IBopConnectionStringInfo nopConnectionString) { if (nopConnectionString is null) { throw new ArgumentNullException(nameof(nopConnectionString)); } if (nopConnectionString.IntegratedSecurity) { throw new BopException("Data provider supports connection only with login and password"); } var builder = new MySqlConnectionStringBuilder { Server = nopConnectionString.ServerName, //Cast DatabaseName to lowercase to avoid case-sensitivity problems Database = nopConnectionString.DatabaseName.ToLower(), AllowUserVariables = true, UserID = nopConnectionString.Username, Password = nopConnectionString.Password, }; return(builder.ConnectionString); }