Sorry, but I don't think I am going to be much help to you, as I do nothing using Win32::OLE. Your first question was easy to asnwer because of the error message you posted and the context. This one requires an understanding of OLE which I do not have. Unless someone here pops their head up and chimes in, you may have to take this kind of question to the Active State support forums.
However, looking at your code from my point of view of no knowledge of what you are doing, there are a couple of things that stand out.
MSIObject = CreateObject Win32::OLE 'WindowsInstaller.Installer'; if (defined ($MSIObject)) { print "Object Available\n"; $dbReference = $MSIObject->OpenDatabase( "C:\\temp\\AppsenseApplicationManager.msi", 1 ); $query = "SELECT * FROM Feature WHERE Feature = " . "'Agent'"; $view = $dbReference->OpenView($query); $results = $view->Execute(); $record = $view->Fetch(); if( $record ) { for( my $loop = 0; $loop < $record->FieldCount(); $loop++ ) { print "Field = " . $loop . " = " . $record->StringData($loop) . "\n"; } } else { print "Record is undefined!\n" }
The above part I assume is working.
Then you do this bit
$newRecord = $MSIObject->CreateRecord( $record->FieldCount() ); $newRecord->StringData(1, 'Agent2'); for (my $loop = 0; $loop < $newRecord->FieldCount(); $loop++) { print "New Record Field = " . $loop . " = " . $newRecord->StringData($loop) . "\n"; }
From the evidence of the previous code, the fields are numbered from zero, but you used an index of 1?
But this is a new record. You have only set one field of that record. How could the other fields have any value?
The next thing you try to do is modifythe database.
$view->Modify(9, $newRecord); print "View Error = " . $view->GetError() . "\n"; $dbReference->Commit(); $view->Close(); $dbReference = undef; $reference = undef; }
It is not at all clear to me whether you are trying to modify an existing record, or create a completely new one.
If the former, you shouldn't be creating a new record, you should be querying the record you wish to modify, set the fields as required and then modify the database using that.
If the latter, your expectation that setting one field will cause the other fields to magically obtain some values is forlorn.
Basicaly, you need to find somebody who understands a) what you are trying to do; b) the technology that you are trying to use to do it. I'm afraid that I am neither ofthose people.
In reply to Re^3: Help with OLE module and MSI files
by BrowserUk
in thread Help with OLE module and MSI files
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |