/// <summary> /// Sets the preferred provider by name. This provider is used by all /// newly created instances of AccessDatabase. /// </summary> /// <param name="providerName">The name of the provider to user.</param> public static async Task SetProviderByNameAsync(string providerName) { // *** // *** Check for the preferred provider // *** IOleDbProvider selected = (await MicrosoftAccessProvider.Providers()).Where(t => t.Name == providerName).SingleOrDefault(); if (selected != null) { MicrosoftAccessProvider.Current = selected; MicrosoftAccessProvider.IsPreferred = true; } else { throw new SpecifiedProviderNotFoundException(providerName); } }
private static string GetProviderName() { string returnValue = String.Empty; if (MicrosoftAccessProvider.ProviderFound) { returnValue = MicrosoftAccessProvider.Current.Name; } else { MicrosoftAccessProvider.CheckForAccessProviderAsync().Wait(); if (MicrosoftAccessProvider.ProviderFound) { returnValue = MicrosoftAccessProvider.Current.Name; } else { throw new ProviderNotFoundException(); } } return(returnValue); }