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.

  1. You construct a query, (Records containing the feature 'Agent')
  2. Open a view to that query
  3. Execute that query
  4. Retrieve the first record from that view.
  5. Print out the fields from that record.

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"; }
  1. Create a new record
  2. Set the value of the second field

    From the evidence of the previous code, the fields are numbered from zero, but you used an index of 1?

  3. You then attempt to display all the fields of that record.

    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.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.