This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Populating Combobox with custom action
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 27, 2011
07:44 AM
Populating Combobox with custom action
Hi I am trying to get a combo list to be able to be populated with values that are held in an xml file.
I have tried to get the script below to work but it just falls over, typically installshield giving me not a clue why.
If I run the script without trying to insert an item into the MSI Database so that a message box just appears it works without issue.
Dim objView
Dim objDB
Dim objInstaller
Dim objRecord
Dim SiteName, Bindings, objNode
Set MsiDb = Session.Database
Set MsiInstall = Session.Installer
Set MsiView = MsiDb.OpenView("SELECT * FROM ComboBox")
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.load("c:\test.xml")
Set ElemList = xmlDoc.getElementsByTagName("SITE")
index=0
i=1
SiteName = ElemList.item(index).getAttribute("SITE.NAME")
Bindings = ElemList.item(index).getAttribute("bindings")
For Each objNode in ElemList
Msgbox SiteName + Bindings
'Now Populate the ComboBox with the strRegionName and strRegionValue items
Set objRecord = objInstaller.CreateRecord(4)
objRecord.StringData(1) = "SITELIST" ' property name
objRecord.IntegerData(2) = i' order
objRecord.StringData(3) = SiteName' value
objRecord.StringData(4) = Bindings' text
' now add the record to the table
Call objView.Execute(objRecord)
Call objView.Modify(7, objRecord) ' (7 = msiViewModifyInsertTemporary)
index=index+1
i =i + 1
Next
Call MsiView.Close
I have tried to get the script below to work but it just falls over, typically installshield giving me not a clue why.
If I run the script without trying to insert an item into the MSI Database so that a message box just appears it works without issue.
Dim objView
Dim objDB
Dim objInstaller
Dim objRecord
Dim SiteName, Bindings, objNode
Set MsiDb = Session.Database
Set MsiInstall = Session.Installer
Set MsiView = MsiDb.OpenView("SELECT * FROM ComboBox")
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.load("c:\test.xml")
Set ElemList = xmlDoc.getElementsByTagName("SITE")
index=0
i=1
SiteName = ElemList.item(index).getAttribute("SITE.NAME")
Bindings = ElemList.item(index).getAttribute("bindings")
For Each objNode in ElemList
Msgbox SiteName + Bindings
'Now Populate the ComboBox with the strRegionName and strRegionValue items
Set objRecord = objInstaller.CreateRecord(4)
objRecord.StringData(1) = "SITELIST" ' property name
objRecord.IntegerData(2) = i' order
objRecord.StringData(3) = SiteName' value
objRecord.StringData(4) = Bindings' text
' now add the record to the table
Call objView.Execute(objRecord)
Call objView.Modify(7, objRecord) ' (7 = msiViewModifyInsertTemporary)
index=index+1
i =i + 1
Next
Call MsiView.Close
(6) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 27, 2011
11:43 AM
The objView object never seems to be assigned. You may need to change your code as follows. It still does not work, see InstallShield Developer Tip: Accessing the MSI Database at Run Time.
Dim objView
Dim objDB
Dim objInstaller
Dim objRecord
Dim SiteName, Bindings, objNode
Set MsiDb = Session.Database
Set MsiInstall = Session.Installer
Set objView = MsiDb.OpenView("SELECT * FROM ComboBox")
objView.Execute
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.load("c:\test.xml")
Set ElemList = xmlDoc.getElementsByTagName("SITE")
index=0
i=1
SiteName = ElemList.item(index).getAttribute("SITE.NAME")
Bindings = ElemList.item(index).getAttribute("bindings")
For Each objNode in ElemList
Msgbox SiteName + Bindings
'Now Populate the ComboBox with the strRegionName and strRegionValue items
Set objRecord = objInstaller.CreateRecord(4)
objRecord.StringData(1) = "SITELIST" ' property name
objRecord.IntegerData(2) = i' order
objRecord.StringData(3) = SiteName' value
objRecord.StringData(4) = Bindings' text
' now add the record to the table
' Call objView.Execute(objRecord) <-- Comment out
Call objView.Modify(7, objRecord) ' (7 = msiViewModifyInsertTemporary)
index=index+1
i =i + 1
Next
Call objView.Close
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 28, 2011
03:56 AM
I have tried the changed code and it still falls over.
Any other ideas?
Any other ideas?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 28, 2011
10:05 AM
Make sure that you are using an immediate execution custom action. You may not be able to use a deferred execution custom action for your script because it can only access to a very limited information of installation. For more information, see Obtaining Context Information for Deferred Execution Custom Actions.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 28, 2011
02:39 PM
I also would strongly recommend switching to C# and DTF and don't bother with VB stuff anymore.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 31, 2011
05:18 AM
I have managed to solve the issue, I would switch to C but I don't know a thing about C and haven't got the time to learn
PS what is DTF?
Dim SiteName, Bindings
Const msiViewModifyInsertTemporary = 7
Const IDOK = 1
Set viewlist = Database.OpenView("SELECT * FROM `ComboBox` WHERE `Property`='REGION'")
viewlist.Execute
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
if not xmlDoc.load("c:\test.xml") then
msgbox "Failed to load xml - " & xmlDoc.parseError.reason
end if
r = 0
for each objElement in xmlDoc.documentElement.selectNodes("SITE")
SiteName = objElement.getAttribute("SITE.NAME")
Bindings = objElement.getAttribute("bindings")
Set reclist = Installer.CreateRecord(4)
r = r + 1
reclist.StringData(1) = "REGION"
reclist.IntegerData(2) = r
reclist.StringData(3) = SiteName
reclist.StringData(4) = Bindings + SiteName
viewlist.Modify msiViewModifyInsertTemporary, reclist
Next
PS what is DTF?
Dim SiteName, Bindings
Const msiViewModifyInsertTemporary = 7
Const IDOK = 1
Set viewlist = Database.OpenView("SELECT * FROM `ComboBox` WHERE `Property`='REGION'")
viewlist.Execute
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
if not xmlDoc.load("c:\test.xml") then
msgbox "Failed to load xml - " & xmlDoc.parseError.reason
end if
r = 0
for each objElement in xmlDoc.documentElement.selectNodes("SITE")
SiteName = objElement.getAttribute("SITE.NAME")
Bindings = objElement.getAttribute("bindings")
Set reclist = Installer.CreateRecord(4)
r = r + 1
reclist.StringData(1) = "REGION"
reclist.IntegerData(2) = r
reclist.StringData(3) = SiteName
reclist.StringData(4) = Bindings + SiteName
viewlist.Modify msiViewModifyInsertTemporary, reclist
Next