I created a static helper class to do it:
public class HelperDataAccess
{
private static string _activeConnectionString;
/// <summary>
/// The connection string to use when connecting to the database
/// </summary>
public static string ActiveConnectionString
{
get
{
return _activeConnectionString;
}
set
{
_activeConnectionString = value;
}
}
/// <summary>
/// Common place to get a data adapter object.
/// </summary>
/// <returns>the correct IDataAccessAdapter</returns>
public static IDataAccessAdapter GetDataAdapter()
{
IDataAccessAdapter da = new DataAdapterMSSQL(HelperDataAccess.ActiveConnectionString);
((DataAccessAdapter)da).CatalogNameUsageSetting = CatalogNameUsage.Clear;
return da;
}
}
at app load i set the active connection string property which is static and should never change and then call the getdataadapter method which creates the adapter with the correct connection string, I also have mine own dataadapter I use so i can trap save and delete events but all you would need to do is return the regular adapter