Collapse All Expand All Code: All Code: Multiple Code: C# Code: Visual Basic Code: Visual C++

C#
Visual Basic
Visual C++

Berkeley DB .NET API Documentation
Database..::.Open Method (String, String, DatabaseConfig, Transaction)
Database Class See Also Send Feedback

Instantiate a new Database object and open the database represented by Filename and DatabaseName. The file specified by Filename must exist.

Namespace: BerkeleyDB
Assembly: libdb_dotnet62 (in libdb_dotnet62.dll) Version: 6.2.32.0

# Syntax

C#
    public static Database Open(
    	string Filename,
    	string DatabaseName,
    	DatabaseConfig cfg,
    	Transaction txn
    )

Visual Basic (Declaration)
    Public Shared Function Open ( _
    	Filename As String, _
    	DatabaseName As String, _
    	cfg As DatabaseConfig, _
    	txn As Transaction _
    ) As Database

Visual C++
    public:
    static Database^ Open(
    	String^ Filename,
    	String^ DatabaseName,
    	DatabaseConfig^ cfg,
    	Transaction^ txn
    )

#### Parameters

Filename
  Type: System..::.String
  The name of an underlying file used to back the database. In-memory databases never intended to be preserved on disk may be created by setting this parameter to null.

DatabaseName
  Type: System..::.String
  This parameter allows applications to have multiple databases in a single file. Although no DatabaseName needs to be specified, it is an error to attempt to open a second database in a file that was not initially created using a database name.

cfg
  Type: BerkeleyDB..::.DatabaseConfig
  The database's configuration

txn
  Type: BerkeleyDB..::.Transaction
  If the operation is part of an application-specified transaction, txn is a Transaction object returned from BeginTransaction()()(); if the operation is part of a Berkeley DB Concurrent Data Store group, txn is a handle returned from BeginCDSGroup()()(); otherwise null.

#### Return Value

A new, open database object

# Remarks

If both Filename and DatabaseName are null, the database is strictly temporary and cannot be opened by any other thread of control, thus the database can only be accessed by sharing the single database object that created it, in circumstances where doing so is safe. If Filename is null and DatabaseName is non-null, the database can be opened by other threads of control and be replicated to client sites in any replication group.

If txn is null, but AutoCommit is set, the operation is implicitly transaction protected. Transactionally protected operations on a database object requires the object itself be transactionally protected during its open. The transaction must be committed before the object is closed.

# See Also

Database Class
Open Overload
BerkeleyDB Namespace