Skip to main content

CannotFindAppropriateConnectionProviderException Class

Occurs when a connection string or an IDbConnection object is not compatible with data store providers.

Namespace: DevExpress.Xpo.Exceptions

Assembly: DevExpress.Xpo.v24.2.dll

Declaration

public class CannotFindAppropriateConnectionProviderException :
    Exception

Remarks

The GetConnectionProvider method can throw a CannotFindAppropriateConnectionProvider exception if none of the data store providers (an IDataStore implementations) can accept parameter values (connectionString or connection).

Solution

XPO supplies a set of data store providers: Database Systems Supported by XPO. Most of them need the XpoProvider attribute in the connection string. To get a fully qualified connection string, use the GetConnectionString method of a corresponding connection provider.

A custom data store provider should implement additional static methods to support the GetConnectionProvider method. The DataStoreCreationFromConnectionDelegate and DataStoreCreationFromStringDelegate delegates describe the signature and return types of these methods. Use the RegisterDataStoreProvider method to register them.

public static IDataStore CreateProviderFromString(string connectionString, AutoCreateOption autoCreateOption, 
  out IDisposable[] objectsToDisposeOnDisconnect) {
    IDbConnection connection = CreateConnection(connectionString);
    objectsToDisposeOnDisconnect = new IDisposable[] { connection };
    return CreateProviderFromConnection(connection, autoCreateOption);
}
public static IDataStore CreateProviderFromConnection(IDbConnection connection, AutoCreateOption autoCreateOption) {
    return new AseClientConnectionProvider(connection, autoCreateOption);
}
static AseClientConnectionProvider() {
    RegisterDataStoreProvider(XpoProviderTypeString, new DataStoreCreationFromStringDelegate(CreateProviderFromString));
    RegisterDataStoreProvider(AseConnectionShortName, new DataStoreCreationFromConnectionDelegate(CreateProviderFromConnection));
}

Inheritance

Object
Exception
CannotFindAppropriateConnectionProviderException
See Also