/// <summary> /// Gets a View object representing the query specified by a SQL string. /// </summary> /// <param name="sqlFormat">SQL query string, which may contain format items</param> /// <param name="args">Zero or more objects to format</param> /// <returns>A View object representing the query specified by a SQL string</returns> /// <exception cref="BadQuerySyntaxException">the SQL syntax is invalid</exception> /// <exception cref="InvalidHandleException">the Database handle is invalid</exception> /// <remarks><p> /// The <paramref name="sqlFormat"/> parameter is formatted using <see cref="String.Format(string,object[])"/>. /// </p><p> /// The View object should be <see cref="InstallerHandle.Close"/>d after use. /// 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. /// </p><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msidatabaseopenview.asp">MsiDatabaseOpenView</a> /// </p></remarks> public View OpenView(string sqlFormat, params object[] args) { if (string.IsNullOrWhiteSpace(sqlFormat)) { throw new ArgumentNullException("sqlFormat"); } string sql = (args == null || args.Length == 0 ? sqlFormat : String.Format(CultureInfo.InvariantCulture, sqlFormat, args)); int viewHandle; uint ret = RemotableNativeMethods.MsiDatabaseOpenView((int)this.Handle, sql, out viewHandle); if (ret != 0) { throw InstallerException.ExceptionFromReturnCode(ret); } return(new View((IntPtr)viewHandle, sql, this)); }