Database Constructor (filePath, mode)

DTF API

Copy image CopyHover image
Deployment Tools Foundation Database Constructor (filePath, mode)
Deployment Tools Foundation NamespacesMicrosoft.Deployment.WindowsInstallerDatabaseDatabase(String, DatabaseOpenMode)
Opens an existing database or creates a new one.
Declaration Syntax
C# Visual Basic Visual C++ F#
public Database(
	string filePath,
	DatabaseOpenMode mode
)
Public Sub New ( 
	filePath As String,
	mode As DatabaseOpenMode
)
public:
Database(
	String^ filePath, 
	DatabaseOpenMode mode
)
new : 
        filePath : string * 
        mode : DatabaseOpenMode -> Database
Parameters
filePath (String)
Path to the database file. If an empty string is supplied, a temporary database is created that is not persisted.
mode (DatabaseOpenMode)
Open mode for the database
Remarks

Because this constructor initiates database access, it cannot be used with a running installation.

The database object should be Close()()()()d after use. The finalizer will close the handle if it is still open, however due to the nondeterministic nature of finalization it is best that the handle be closed manually as soon as it is no longer needed, as leaving lots of unused handles open can degrade performance.

A database opened in CreateDirect or Direct mode will be automatically commited when it is closed. However a database opened in Create or Transact mode must have the Commit()()()() method called before it is closed, otherwise no changes will be persisted.

Win32 MSI API: MsiOpenDatabase

Exceptions
Exception Condition
InstallerException the database could not be created/opened

Assembly: Microsoft.Deployment.WindowsInstaller (Module: Microsoft.Deployment.WindowsInstaller.dll) Version: 3.0.0.0 (3.11.1.2318)