View.Execute 方法

View物件的Execute方法會使用問號標記來表示 SQL 語句中的參數。 如需詳細資訊,請參閱 SQL 語法。 這些參數的值會當做參數記錄的對應欄位傳入。

語法

View.Execute(
  record
)

參數

record

選擇性 Record 物件,其中包含在 SQL 查詢中取代參數標記 (?) 的值。

傳回值

這個方法不會傳回值。

備註

呼叫 Fetch 方法之前,必須先呼叫這個方法。

如果 SQL 查詢指定參數標記的值 (?) ,則必須提供包含所有取代值的記錄,其順序和資料類型必須與參數標記相同。 當這個方法與 INSERT 和 UPDATE 查詢搭配使用時,問號標記必須在所有非參數化值之前。

例如,這些查詢有效:

UPDATE {table-list} SET {column}= ? ,{column}= {constant}

INSERT INTO {table} ({column-list}) VALUES (?, {constant-list})

不過,這些查詢無效:

UPDATE {table-list} SET {column}= {constant}, {column}=?

INSERT INTO {table} ({column-list}) VALUES ({constant-list}, ?)

如果方法失敗,您可以使用 LastErrorRecord 方法來取得擴充錯誤資訊。

規格需求

需求
版本
Windows Server 2012、Windows 8、Windows Server 2008 R2 或 Windows 7 上的 Windows Installer 5.0。 Windows Server 2008 或 Windows Vista 上的 Windows Installer 4.0 或 Windows Installer 4.5。 Windows Server 2003 或 Windows XP 上的 Windows Installer
DLL
Msi.dll
IID
IID_IView定義為 000C109C-0000-0000-C000-000000000046