Jump to content


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.
Photo

How to query tables of ActiveDatabase


3 replies to this topic

vishnub

vishnub
  • Full Members
  • 63 posts

Posted 15 December 2004 - 18:49

Hi All,

I am using InstallScriptMsi project, i created a custom table. I need to query the table during runtime. I searched the InstallShield Help Library, everywhere i found example in VBScript. I need to know how to do it in InstallScript. I tried with InstallScript, but my script does not retrieve values. Here is my code, can anyone point out the mistake in the following code, or give me a sample how to query the msi tables during runtime.

function ReadMSI()
NUMBER hView, hDatabase,hRec,hInstall,nvBufferSize;
STRING svValue;
POINTER pView;
begin
pView = &hView;
hDatabase = MsiGetActiveDatabase(hInstall);
MsiDatabaseOpenView(hDatabase,"SELECT * FROM Feature", pView);
hRec = MsiCreateRecord(5);
MsiViewExecute(hView,hRec);
MsiRecordGetString(hRec,1,svValue,nvBufferSize);
MessageBox(svValue,INFORMATION);
MsiCloseHandle(hRec);
MsiViewClose(hView);
MsiCloseHandle(hDatabase);
end;

Can anyone help me to get this done?

Thanks in Advance,

Vishnu
smile.gif

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 16 December 2004 - 07:47

You need to initialize nvBufferSize to the size of your buffer.

vishnub

vishnub
  • Full Members
  • 63 posts

Posted 16 December 2004 - 10:03


Thanks Stefan, I got a link which given the example in InstallScript.
http://helpnet.insta...&agt=wsm&ctxid=

But i cant able to retrieve the value from the table. Here is the modified piece of code as like the example.

function ReadMSI(hInstall)
HWND hView, hDatabase,hRec;
NUMBER nvBufferSize;
STRING svValue;
begin
hDatabase = MsiGetActiveDatabase(hInstall);
MsiDatabaseOpenView(hDatabase,"SELECT * FROM 'Feature'", hView);
MsiViewExecute(hView,NULL);
while(MsiViewFetch(hView, hRec) != ERROR_NO_MORE_ITEMS)
nvBufferSize = 256;
MsiRecordGetString(hRec, 3, svValue, nvBufferSize);
MessageBox(svValue,INFORMATION);
endwhile;
MsiViewClose(hView);
end;

i given value to the buffer variable, and called some debugging messageboxes to check whether the record is null or not. It returns not null. Can you point out the mistake in the above piece of code.

Thanks
Vishnu
rolleyes.gif

vishnub

vishnub
  • Full Members
  • 63 posts

Posted 20 December 2004 - 09:55

Thanks Stefan,

I got it done, one of the InstallShield Sr.Technical Engineer helped to sort out the problem. There is a typographical error in that link, instead of backquotes (`) they put apostrophes (') and previously i passed the Windows handle instead of MSI database handle. Here is the correct form of the code

function ReadMSI(hInstall)
HWND hView, hDatabase,hRec;
NUMBER nvBufferSize,nCount;
STRING svValue;
begin
hDatabase = MsiGetActiveDatabase(hInstall);
MsiDatabaseOpenView(hDatabase,"SELECT * FROM `Feature`", hView);
MsiViewExecute(hView,NULL);
while(MsiViewFetch(hView, hRec) != ERROR_NO_MORE_ITEMS)
nvBufferSize = 256;
MsiRecordGetString(hRec, 1, svValue, nvBufferSize);
MessageBox(svValue,INFORMATION);
endwhile;
MsiViewClose(hView);
end;

pass ISMSI_HANDLE to the function instead of Windows handle.

Regards
Vishnu