xpo-devexpress-dot-xpo-dot-db-9557b361.md
Implements data-aware operations for working with Microsoft Access databases.
Namespace : DevExpress.Xpo.DB
Assembly : DevExpress.Xpo.v25.2.dll
NuGet Package : DevExpress.Xpo
public class AccessConnectionProvider :
OleDBConnectionProvider,
ISqlGeneratorFormatterEx,
ISqlGeneratorFormatter
Public Class AccessConnectionProvider
Inherits OleDBConnectionProvider
Implements ISqlGeneratorFormatterEx,
ISqlGeneratorFormatter
The AccessConnectionProvider class implements data-aware operations for working with Microsoft Access databases. In most cases, there is no need to create connection providers explicitly, as they are created automatically by a Session object based upon the connection string.
To connect to a specific Microsoft Access database, you can generate a connection string via the static AccessConnectionProvider.GetConnectionString method. To open Microsoft Access 2007 databases, use the AccessConnectionProvider.GetConnectionStringACE method.
This connection string will contain information on the provider ( AccessConnectionProvider ) that will be used to work with the database. Supply this connection string to a Session object (for instance, via the Session.ConnectionString or XpoDefault.ConnectionString property). When a connection to a database is to be established, the session will create a corresponding connection provider based upon the connection string, and then perform all data-aware operations using this connection provider.
There are also cases when you need to create a connection provider explicitly via its constructor, for instance:
Note
If you are developing a multi-user and multi-threaded application and data consistency between threads and users is important, use the AccessConnectionProviderMultiUserThreadSafe provider instead of the AccessConnectionProvider class. So, use the AccessConnectionProviderMultiUserThreadSafe.GetConnectionString method instead of the AccessConnectionProvider.GetConnectionString method to obtain a connection string.
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");
Imports DevExpress.Xpo
Imports DevExpress.Xpo.DB
XpoDefault.ConnectionString = AccessConnectionProvider.GetConnectionString( _
"c:\Data\nwind.mdb")
Object MarshalByRefObject DevExpress.Xpo.DB.DataStoreSerializedBase DataStoreBase ConnectionProviderSql OleDBConnectionProvider AccessConnectionProvider
See Also
AccessConnectionProvider Members