cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jchristman
Level 8

VBScript SQL Combo box

Trying to run a sql select statement to retrieve a list and load it into a combo box. I have tried applying the same concept as the VBScript ComboBox that i used for IIS site listings. but my script either hangs or errors

Here is what I have.


Option Explicit
On Error Resume Next

Dim TESTSTRING

Dim objView
Dim objDB
Dim objInstaller
Dim objBindingList
Dim objRecord
Dim objW3SVC, objIisWebSite
Dim lngOrder
Dim o_SQL, o_Reader, o_Connection

Set objDB = Session.Database
Set objInstaller = Session.Installer
Set objView = objDB.OpenView("select * from ComboBox")

' enumerate webservers on localhost and populate ComboBox table
Set o_Connection = CreateObject("ADODB.Connection")
Set o_SQL = CreateObject("ADODB.Command")
Set o_Reader = CreateObject("ADODB.RecordSet")

o_Connection.Provider = "SQLOLEDB.1"
o_Connection.Properties("Data Source").Value = Session.Property("IS_SQLSERVER_SERVER")
o_Connection.Properties("Initial Catalog").Value = "MYDATABASE"

If GetProp("IS_SQLSERVER_USERNAME") < " " Then
o_Connection.Properties("Integrated Security").Value = "SSPI"
Else
o_Connection.Properties("Persist Security Info").Value = False
o_Connection.Properties("User ID").Value = GetProp("IS_SQLSERVER_USERNAME")
o_Connection.Properties("Password").Value = GetProp("IS_SQLSERVER_PASSWORD")
End If

o_Connection.Open

Set o_SQL.ActiveConnection = o_Connection
o_SQL.CommandText = "SELECT Field1, Field2 FROM MYDATABASE.dbo.MYTABLE"

Set o_Reader = o_SQL.Execute

o_Reader.MoveFirst

lngOrder = 1
Do Until o_Reader.EOF
add site name to ComboBox table (which is used by our dialog ComboBox)
Set objRecord = objInstaller.CreateRecord(4)
objRecord.StringData(1) = "MYLIST" ' property name
objRecord.IntegerData(2) = lngOrder ' order
objRecord.StringData(3) = o_Reader.Fields("field1").Value' value
objRecord.StringData(4) = o_Reader.Fields("field2").Value ' text

' now add the record to the table
Call objView.Execute(objRecord)
Call objView.Modify(7, objRecord) ' (7 = msiViewModifyInsertTemporary)

lngOrder = lngOrder + 1
o_Reader.MoveNext
Loop

Call objView.Close


' Supplemental Functions and Subs for Working with InstallShield
Sub SetProp(s_PropertyName, s_PropertyValue)
Session.Property(s_PropertyName) = s_PropertyValue
End Sub

Function GetProp(s_PropertyName)
GetProp = Session.Property(s_PropertyName)
End Function
Labels (1)
0 Kudos
(1) Reply
jchristman
Level 8

I have figured out now that the code seems to be correct in appearance, althought I have traced down that it does not error it simply gets stuck in the loop never hitting EOF causing the processor to climb to 100% and just keeps running unless reset manually.

any suggestions?
0 Kudos