PDA

View Full Version : Change value in Db Table



NewsArchive
12-06-2001, 01:00 AM
Hi,

All my attempts to change the value of the specific record in DB Table
during run-time failed.
Here is a piece of code that I use:


// Obtain a handle to the active database
hDataBase = MsiGetActiveDatabase(hMsi);

if(hDataBase = 0) then
MessageBox("Unable to open active database", SEVERE);
exit;
endif;
szSQLQuery = "SELECT * FROM " + szTableName;
// Create a view object as specified by szQuery
nResult = MsiDatabaseOpenView(hDataBase, szSQLQuery, hView);

if(nResult != ERROR_SUCCESS) then
MsiCloseHandle(hDataBase);
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(nReturn != ERROR_SUCCESS) then
MsiCloseHandle(hDataBase);
MsiCloseHandle(hView);
return ERROR_INSTALL_FAILURE;
endif;


MsiRecordSetString(hRecord, nField, szPropertyValue);

nReturn = MsiViewModify(hView, MSIMODIFY_UPDATE, hRecord);

if(nReturn != ERROR_SUCCESS) then
MsiCloseHandle(hRecord);
MsiCloseHandle(hDataBase);
MsiCloseHandle(hView);
return ERROR_INSTALL_FAILURE;
endif;

MsiCloseHandle(hRecord);
MsiCloseHandle(hDataBase);
MsiCloseHandle(hView);

..........


MsiViewModify returns Error code (with MSIMODIFY_UPDATE flag). If use
MSIMODIFY_REFRESH flag the functions succeeded but it has no effect and the
value returns unchanged.


Any ideas? Has anybody used it and succeeded ?

Thanks,
Evgeny.