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.

Populating a ListBox with a Custom Action

2 replies to this topic


  • Full Members
  • 34 posts

Posted 26 April 2004 - 13:24

Help, I am trying to populate a list box with the SQL Servers names using SQLDMO Application in a VBScript Custom Action. I am using InstallShield Professional – Windows Installer v2.03. I have created the list box on a dialog and I have a button to retrive the SQL Server names (DoAction to call Custom Action). I got the example from here (ListSQLServers.vbs) but I can’t seem to get it to populate the list box. Any suggestion would be appreciated. I have included the vbs code below.

Function ListDisplay()

Set objInstaller = Session.Installer

Set objDatabase = Session.Database

' open and execute a view to the ListBox table
Set viewlist = objDatabase.OpenView("SELECT * FROM `ListBox` WHERE `Property`= 'LISTBOXPROP'")


r = 0

' ListBox record fields are Property, Order, Value, Text
Set reclist = objInstaller.CreateRecord(4)

'Use the SQL DMO Application Object to find the available SQL Servers
Set oSQLServerDMOApp = New SQLDMO.Application

Set namX = oSQLServerDMOApp.ListAvailableSQLServers
For i = 1 To 4 'namX.Count

reclist.StringData(1) = "LISTBOXPROP"
reclist.IntegerData(2) = r
reclist.StringData(3) = namx.item(i)
reclist.StringData(4) = namx.item(i)

' insert the temporary ListBox record
viewlist.Modify 7, reclist

r = r + 1


' clean up
Set oSQLServerDMOApp = Nothing
Set namex = Nothing

' return success to MSI
ListDisplay = 1
End Function



  • Members
  • 2 posts

Posted 26 April 2004 - 19:19

looks like you forgot to declare a NameList for the SQL Server...

Dim oApp As New SQLDMO.Application
Dim oNames As SQLDMO.NameList
Dim iCtr As Integer

Set oApp = CreateObject("SQLDMO.Application")
Set oNames = oApp.ListAvailableSQLServers()

For iCtr = 1 To oNames.Count
List1.AddItem oNames.Item(iCtr)

Set oApp = Nothing
Set oNames = Nothing

I create a blank project create a listbox and put the above code into the FormLoad event and I get a list of SQL Servers that are on my current domain... just replace the line:
List1.AddItem oNames.Item(iCtr)
with your code to add to the list box....
Steve Ogilvie

Keep the light on human rights - go to www.amnesty.ca


  • Full Members
  • 34 posts

Posted 26 April 2004 - 19:57

Thanks, but I am trying to use VBScript in a Custom Action and I don't have a FormLoad event. Yes, I have been able to this to work in VB but for some reason VBScript does not like the Dim As statement (crashes). I don't have a debugger so all I have been able to do is place MsgBox in various places in the code so I could fine where and on what the code crashed.

Jim Copenhaver