The MsiDatabaseOpenView function prepares a database query and creates a view object. This function returns a handle that should be closed using MsiCloseHandle.
Syntax
C++UINT MsiDatabaseOpenView(
__in MSIHANDLE hDatabase,
__in LPCTSTR szQuery,
__out MSIHANDLE *phView
);
Parameters
- hDatabase [in]
-
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.
- szQuery [in]
-
Specifies a SQL query string for querying the database. For correct syntax, see SQL Syntax.
- phView [out]
-
Pointer to a handle for the returned view.
Return Value
The MsiDatabaseOpenView function returns one of the following values:
- ERROR_BAD_QUERY_SYNTAX
-
An invalid SQL query string was passed to the function.
- ERROR_INVALID_HANDLE
-
An invalid or inactive handle was supplied.
- ERROR_SUCCESS
-
The function succeeded, and the handle is to a view object.
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.
Requirements
Version | Windows 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 |
---|---|
Header | Msiquery.h |
Library | Msi.lib |
DLL | Msi.dll |
Unicode and ANSI names | MsiDatabaseOpenViewW (Unicode) and MsiDatabaseOpenViewA (ANSI) |
See Also
Send comments about this topic to Microsoft
Build date: 8/13/2009
© 2009 Microsoft Corporation. All rights reserved.