Hi All,
In my Standard project I use function called during OnInstallFilesActionAfter event. In this function I read a record from DataBase and retrieve a value. There are some cases happened randomly when MsiViewFetch returns ERROR_INVALID_HANDLE (15% from all cases). Here is my code:
function DBGetValue (hInstall, szSQLQuery, nField, szColumnType, szPropertyValue, nValue)
NUMBER nResult, nBufSize;
HWND hView, hRecord, hDataBase;
begin
// Obtain a handle to the active database
hDataBase = MsiGetActiveDatabase(hInstall);
if(hDataBase = 0) then
MessageBox("Unable to open active database", SEVERE);
exit;
endif;
// Create a view object as specified by szQuery
nResult = MsiDatabaseOpenView(hDataBase, szSQLQuery, hView);
if(nResult != ERROR_SUCCESS) then
MsiCloseHandle(hDataBase);
MsiCloseHandle(hView);
return ERROR_INSTALL_FAILURE;
endif;
// Execute the view object and make it
// ready for retrieving records
nResult = MsiViewExecute(hView, NULL);
if(nResult != ERROR_SUCCESS) then
MsiCloseHandle(hDataBase);
MsiCloseHandle(hView);
return ERROR_INSTALL_FAILURE;
endif;
nResult = MsiViewFetch(hView, hRecord);
if(nResult != ERROR_SUCCESS) then
MsiCloseHandle(hDataBase);
MsiCloseHandle(hView);
MsiCloseHandle(hRecord);
return ERROR_INSTALL_FAILURE;
endif;
// Explicitly set the value buffer to an empty string
// so we can obtain the required buffer size
switch ( szColumnType )
case "STRING":
// Explicitly set the value buffer to an empty string
// so we can obtain the required buffer size
szPropertyValue = "";
nBufSize = 0;
MsiRecordGetString(hRecord, nField, szPropertyValue,
nBufSize);
// Now that we know the required buffer size set the
// buffer size and get the property value
nBufSize = nBufSize + 1;
Resize(szPropertyValue, nBufSize);
MsiRecordGetString(hRecord, nField, szPropertyValue,
nBufSize);
case "INTEGER":
nValue = MsiRecordGetInteger (hRecord, nField);
default :
MessageBox ("Binary Type", INFORMATION);
MsiCloseHandle(hRecord);
MsiCloseHandle(hDataBase);
MsiCloseHandle(hView);
return ERROR_SUCCESS;
endswitch;
MsiCloseHandle(hRecord);
MsiCloseHandle(hDataBase);
MsiCloseHandle(hView);
return ERROR_SUCCESS;
end;
Any help will be appreciated.
___
Thanks,
Evgeny.
This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
ERROR_INVALID_HANDLE and MsiViewFetch
Started by
lokshin
, Mar 31 2002 15:40
1 reply to this topic
Posted 05 April 2002 - 18:56
Moving to appropriate forum
Stefan Krüger
InstallSite.org twitter facebook