cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
msaponaro
Level 3

Add Item to ComboBox

The function PopulateComboBox add items in a combo box.
The row in red returns error 1627 (ERROR_FUNCTION_FAILED).
I call the function PopulateComboBox on button click in a dialog
In the same dialog there is a combo box with the property = PROP_COMBO
(The project is Basic MSI)
Thanks!!


function PopulateComboBox(hInstall)
NUMBER nResult, hDatabase, hCboView, index;
STRING sQuery;
begin
hDatabase = MsiGetActiveDatabase(hInstall);
sQuery = "SELECT * FROM ComboBox WHERE Property='PROP_COMBO'";
nResult = MsiDatabaseOpenView(hDatabase, sQuery, hCboView);
if (nResult = ERROR_SUCCESS) then
AddCboEntry(hCboView, "PROP_COMBO", "United States", "United States", 1);
AddCboEntry(hCboView, "PROP_COMBO", "Canada", "Canada", 2);
AddCboEntry(hCboView, "PROP_COMBO", "Mexico", "Mexico", 3);
AddCboEntry(hCboView, "PROP_COMBO", "Puerto Rico", "Puerto Rico", 4);
endif;
MsiViewClose(hCboView);
end;


function AddCboEntry(hView, szProperty, szText, szValue, nIndex)
NUMBER hRec;
NUMBER res;
begin
hRec = MsiCreateRecord(4);
res = MsiRecordSetString(hRec, 1, szProperty);
res = MsiRecordSetInteger(hRec, 2, nIndex);
res = MsiRecordSetString(hRec, 3, szText);
res = MsiRecordSetString(hRec, 4, szValue);
res = MsiViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRec);
MsiCloseHandle(hRec);
end;
Labels (1)
0 Kudos
(2) Replies
RobertDickau
Flexera Alumni

Perhaps try executing the view (with MsiViewExecute) after calling MsiDatabaseOpenView? If you haven't yet, perhaps also see the InstallScript help topic "Windows Installer API Functions Example" and this newsletter tip (PDF warning): http://www.macrovision.com/webdocuments/PDF/msiaccess.pdf?link_id=community.
0 Kudos
marvinison
Level 2

fyi, the code above worked for me, didnt have to change anything. (thanks)
0 Kudos