Installer.OpenDatabase Method

Windows Installer

Installer.OpenDatabase Method

The OpenDatabase method of the Installer object opens an existing database or creates a new one, returning a Database object. It generates an error if the Database object cannot be successfully created and opened.

Syntax

Script
OpenDatabase(
  name,
  openMode
)

Parameters

name

Required string that contains the path name of the database. If an empty string is supplied, a temporary database is created that is not persisted.

openMode

A parameter from the following list or a string that contains the path name of the new output database file that is to be written to upon commit.

Parameter Meaning
msiOpenDatabaseModeReadOnly
0

Opens a database read-only, no persistent changes.

msiOpenDatabaseModeTransact
1

Opens a database read/write in transaction mode.

msiOpenDatabaseModeDirect
2

Opens a database direct read/write without transaction.

msiOpenDatabaseModeCreate
3

Creates a new database, transact mode read/write.

msiOpenDatabaseModeCreateDirect
4

Creates a new database, direct mode read/write.

msiOpenDatabaseModeListScript
5

Opens a database to view advertise script files, such as the files generated by the CreateAdvertiseScript method.

msiOpenDatabaseModePatchFile
32

Adds this flag to indicate a patch file.

 

Return Value

This method does not return a value.

Remarks

When a database is opened as the output of another database, the summary information stream of the output database is actually a read-only mirror of the original database and thus cannot be changed. Additionally, it is not persisted with the database. To create or modify the summary information for the output database it must be closed and reopened.

To make and save changes to a database first open the database in transaction (msiOpenDatabaseModeTransact), create (msiOpenDatabaseModeCreate or msiOpenDatabaseModeCreateDirect), or direct (msiOpenDatabaseModeDirect) mode. After making the changes, always call the Commit method before closing the database handle. The Commit method flushes all buffers.

Always call the Commit method on a database that has been opened in direct mode (msiOpenDatabaseModeDirect or msiOpenDatabaseModeCreateDirect) before closing the database. Failure to do this may corrupt the database.

Because the OpenDatabase method initiates database access, it cannot be used with a running installation.

If the method fails, you can obtain extended error information by using the LastErrorRecord method.

Requirements

VersionWindows Installer 5.0 on Windows Server 2008 R2 or Windows 7. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. Windows Installer on Windows Server 2003, Windows XP, and Windows 2000
DLLMsi.dll
IIDIID_IInstaller is defined as 000C1090-0000-0000-C000-000000000046

See Also

Installer

Send comments about this topic to Microsoft

Build date: 8/13/2009

© 2009 Microsoft Corporation. All rights reserved.