Implements an Microsoft Access connection provider that can be used in multi-user and multi-threaded applications.
NuGet Package: DevExpress.Xpo
public class AccessConnectionProviderMultiUserThreadSafe : MarshalByRefObject, IDataStore, IDataStoreAsync, IDataStoreSchemaExplorer, IDataStoreForTests, ICommandChannel, ICommandChannelAsync
Public Class AccessConnectionProviderMultiUserThreadSafe Inherits MarshalByRefObject Implements IDataStore, IDataStoreAsync, IDataStoreSchemaExplorer, IDataStoreForTests, ICommandChannel, ICommandChannelAsync
Unlike the AccessConnectionProvider, the AccessConnectionProviderMultiUserThreadSafe provider can be safely used in multi-user and multi-threaded applications.
The Microsoft Access caches data when modifications are being made to the database. These delayed updates can cause old data to be returned when reading from the database using another connection. The AccessConnectionProviderMultiUserThreadSafe solves these problems by re-creating a connection to the database each time an operation on a database should be carried out. Connecting to the database using this provider is slower than using the AccessConnectionProvider.
See the AccessConnectionProvider topic for more information.
The following code demonstrates how to connect to an Microsoft Access database. The AccessConnectionProvider.GetConnectionString method is called to construct a connection string to the database. It’s then assigned to the XpoDefault.ConnectionString property.
When a connection is about to be established to a database, a session object obtains the connection string from the XpoDefault.ConnectionString property (unless another connection string is supplied directly to the session). This is then used to connect to the database.
using DevExpress.Xpo; using DevExpress.Xpo.DB; XpoDefault.ConnectionString = AccessConnectionProvider.GetConnectionString( @"c:\Data\nwind.mdb");