MsiDatabaseOpenViewW function (msiquery.h)

The MsiDatabaseOpenView function prepares a database query and creates a view object. This function returns a handle that should be closed using MsiCloseHandle.

Syntax

UINT MsiDatabaseOpenViewW(
  [in]  MSIHANDLE hDatabase,
  [in]  LPCWSTR   szQuery,
  [out] MSIHANDLE *phView
);

Parameters

[in] hDatabase

Handle to the database to which you want to open a view object. You can get the handle as described in Obtaining a Database Handle.

[in] szQuery

Specifies a SQL query string for querying the database. For correct syntax, see SQL Syntax.

[out] phView

Pointer to a handle for the returned view.

Return value

The MsiDatabaseOpenView function returns one of the following values:

Remarks

The MsiDatabaseOpenView function opens a view object for a database. You must open a view object for a database before performing any execution or fetching.

If an error occurs, you can call MsiGetLastErrorRecord for more information.

Note that it is recommended to use variables of type PMSIHANDLE because the installer closes PMSIHANDLE objects as they go out of scope, whereas you must close MSIHANDLE objects by calling MsiCloseHandle. For more information see Use PMSIHANDLE instead of HANDLE section in the Windows Installer Best Practices.

If the function fails, you can obtain extended error information by using MsiGetLastErrorRecord.

Note

The msiquery.h header defines MsiDatabaseOpenView as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows Installer 5.0 on Windows Server 2012, Windows 8, 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 or Windows XP
Target Platform Windows
Header msiquery.h
Library Msi.lib
DLL Msi.dll

See also

General Database Access Functions