Hi,
How do I call a function defined in my vbscript using the Custom Action.
I am trying to get the databases from the sqlserver and would like to populate my combobox with property DBCOMBO_PROP with the list of databases.
I tried using the new attached custom action.
Source path: C:\test\PopulateDBList.vbs
Source type : Visual basic Script (*.vbs)
Function Name: GetDatabaseNames
the Install fails when executing this custom action.
If I leave the function name blank, then the install executes the custom action but my retur code is 0. and no value shows up in my combo.
Please help.
Thanks in advance.
following is my vbscript PopulateDBList.vbs.
-------------------------
Const msiViewModifyInsertTemporary = 7
Const IDOK = 1
Function GetDatabaseNames( )
Dim srv
Dim objDB
Set srv = CreateObject("SQLDMO.SQLServer")
srv.LoginTimeout = 15
srv.Connect "shylajar3\GP10", "sa", "wstest" 'Session.Property("SELSERVER_PROP"), "sa" , Session.Property("SAPASSWORD_PROP")
Set objDB = CreateObject("SQLDMO.Database")
Set viewlist = Database.OpenView("SELECT * FROM `ComboBox` WHERE `Property` ='DBCOMBO_PROP'")
viewlist.Execute
Set reclist = viewlist.Fetch
' delete any existing records
While Not (reclist Is Nothing)
viewlist.Modify 6, reclist ' 6 = delete
Set reclist = viewlist.Fetch
Wend
viewlist.Close
' open and execute a view to the ListBox table
'Set viewlist = Database.OpenView("SELECT * FROM `ComboBox` WHERE `Property` ='DBCOMBO_PROP'")
'viewlist.Execute
r = 0
For Each objDB In srv.Databases
If objDB.SystemObject = False Then
' ListBox record fields are Property, Order, Value, Text
'Set reclist = Installer.CreateRecord(4)
r = r + 1
'reclist.StringData(1) = "DBCOMBO_PROP"
'reclist.IntegerData(2) = r
'reclist.StringData(3) = objDB.Name
'reclist.StringData(4) = objDB.Name
' insert the temporary ListBox record
'viewlist.Modify msiViewModifyInsertTemporary, reclist
SQLCmd = "INSERT INTO `ComboBox` (`Property`,`Order`,`Value`,`Text`)"
SQLCmd = SQLCmd & " VALUES ('DBCOMBO_PROP','" & r & "','" & objDB.Name & "','"
SQLCmd = SQLCmd & objDB.Name & "') TEMPORARY"
Set viewlist = Database.OpenView( SQLCmd )
viewlist.Execute
viewlist.Close
End If
Next
' return success to MSI
GetDatabaseNames = IDOK
End Function
------------------------------------