Back to Devexpress

AccessConnectionProviderMultiUserThreadSafe Class

xpo-devexpress-dot-xpo-dot-db-7bc876e8.md

latest3.9 KB
Original Source

AccessConnectionProviderMultiUserThreadSafe Class

Implements an Microsoft Access connection provider that can be used in multi-user and multi-threaded applications.

Namespace : DevExpress.Xpo.DB

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public class AccessConnectionProviderMultiUserThreadSafe :
    MarshalByRefObject,
    IDataStore,
    IDataStoreAsync,
    IDataStoreSchemaExplorer,
    IDataStoreForTests,
    ICommandChannel,
    ICommandChannelAsync
vb
Public Class AccessConnectionProviderMultiUserThreadSafe
    Inherits MarshalByRefObject
    Implements IDataStore,
               IDataStoreAsync,
               IDataStoreSchemaExplorer,
               IDataStoreForTests,
               ICommandChannel,
               ICommandChannelAsync

Remarks

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.

Example

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.

csharp
using DevExpress.Xpo;
using DevExpress.Xpo.DB;

XpoDefault.ConnectionString = AccessConnectionProvider.GetConnectionString(
    @"c:\Data\nwind.mdb");
vb
Imports DevExpress.Xpo
Imports DevExpress.Xpo.DB

XpoDefault.ConnectionString = AccessConnectionProvider.GetConnectionString( _
    "c:\Data\nwind.mdb")

Inheritance

Object MarshalByRefObject AccessConnectionProviderMultiUserThreadSafe

See Also

AccessConnectionProviderMultiUserThreadSafe Members

AccessConnectionProvider

MSSqlConnectionProvider

Session.ConnectionString

XpoDefault.ConnectionString

Data Types Supported by XPO

DevExpress.Xpo.DB Namespace