Saturday, 23 May 2020

VBScript: HTA Code to Fetch recordset values and fill to a combo box

VBScript Help: Create recordset and loop to fetch values:


         <script language="VBScript">

'======================
' Function - FetchSubscriberName
'======================
Function FetchSubscriberName
strSQL = ""
strSQL = strSQL & "SELECT distinct sub_name as sub_name                                                               FROM testsubscription
                        Set recsetApp = RunSQL(strSQL)
With recsetApp
Do While Not recsetApp.EOF
msgbox recsetApp.Fields("sub_name").Value
recsetApp.MoveNext
Loop
End with
End Function
     
</script>


VBScript Help: Create recordset and fill to a combox box


        <script language="VBScript">

'======================

' Function - FetchSubscriberName
'======================

Function FetchSubscriberName

strSQL = ""

strSQL = strSQL & "SELECT distinct sub_name as sub_name FROM                                                  testsubscription where event_name = '" & combobox2.value & "'"

                       Set recsetApp = RunSQL(strSQL)
With recsetApp

Set oDD = document.getelementbyID("Subname")

Do While Not recsetApp.EOF

Set oOpt = oDD.document.createElement("option")

oOpt.Text = recsetApp.Fields("sub_name").Value

oOpt.Value = oOpt.Text

oDD.Options.Add oOpt

'msgbox recsetApp.Fields("sub_name").Value
recsetApp.MoveNext
Loop

End with
End Function     


</script>

No comments:

Post a Comment

VBScript: How to use Dictionary in VBScript | VBScript objects

=>To declare and create object of a vbscript dictionary: Dim objDictionary Set objDictionary = CreateObject("Scripting.Dictionar...