Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Function BuildComboBox(rsSelect,optName,valToMatch)
Dim strList
'NOTE: The recordset option value must represented by the first item => rsSelect(0).Value,
' whereas the option text must be represented by the second item => rsSelect(1).Value
' build up the combo box list.
strList = "<SELECT NAME=" & DblQt(optName) & ">" & vbCRLF
With rsSelect
.MoveFirst
do while not .EOF
strList = strList & "<OPTION VALUE=" & DblQt(rsSelect(0)) & _
setComboOption(rsSelect(0),valToMatch,1) & ">" & rsSelect(1) & "</OPTION>" & vbCRLF
.MoveNext
loop
End With
strList = strList & "</SELECT>" & vbCRLF
' return the combo box list to the caller
BuildComboBox = strList
End Function
Function setComboOption (optValue,DeltaValue,OptionRadio)
' if there is a match then select/check it
if optValue = DeltaValue Then
Select Case OptionRadio
Case 1 ' select
setComboOption = " selected "
Case 2 ' checkbox
setComboOption = " checked "
End Select
End if
End Function
Function ClientList(DeltaValue)
dim combo
' open recordset to get the clientId and client name
Call openRS(rs)
rs.Open "SELECT ClientID, ClientName FROM tblClient ORDER BY ClientName ASC", GetConnection
' create the combo box by passing recordset object, name of combo box,
' option value, option text, and the value to match up with
combo = BuildComboBox(rs,"selClientList",DeltaValue)
' free up the recordset
Call CloseRS(rs)
ClientList = combo
End Function
ClientList(intClientValue)
' PURPOSE: Used for wrapping double quotes around a string
' INPUTS: str - the string to wrap double quotes around
Function DblQt(str)
DblQt = chr(34) & str & chr(34)
End Function
' PURPOSE: Opens the connection and attaches to the connection object
Function GetConnection()
OpenDB()
GetConnection = dbConn
End Function
' PURPOSE: Opens a database connection and sets connection object parameters based on application
' object variables set in the global.asa file
' NAMING CONVENTION: AppName_ConnectionObjectName_ConnectionObjectPropertyName
Function OpenDB()
Set dbConn = Server.CreateObject("ADODB.Connection")
dbConn.ConnectionTimeout = Application("gc_dbConn_ConnectionTimeout")
dbConn.CommandTimeout = Application("gc_dbConn_CommandTimeout")
dbConn.Open Application("gc_dbConn_ConnectionString")
End Function
' PURPOSE: Closes the database connection if the connection is open
Function CloseDB()
' close database connection
if UCase(TypeName(dbConn)) = "CONNECTION" then
dbConn.Close
Set dbConn = Nothing
end if
End Function
' PURPOSE: Opens a database connection, then opens a recordset object
' INPUTS: objRS - recordset object that is to be opened.
Function OpenRS(objRS)
OpenDB()
Set objRS = Server.CreateObject("ADODB.Recordset")
End Function
' PURPOSE: Closes the recordset object passed into function, then closes the connection if
' the connection object is open
' INPUTS: objRS - recordset object that is to be closed.
Function CloseRS(objRS)
Set objRS = Nothing
CloseDB()
End Function