nn, adOpenForwardOnly, adLockReadOnly)
' Else the connection is closed
Else
' Set the ConnectionString
Call SetConnectionString(csConnectionString)
' If atempt To open connection succeeded
If DBConnOpen() Then
' Acquire data With connection object
Call loRS.Open(asSQL, oConn, adOpenForwardOnly, adLockReadOnly)
' Return connection object To closed state
Call DBConnClose()
End If ' DBConnOpen()
End If ' aoConn.State = adStateOpen
' Else active connection is the ConnectionString
Else
' Acquire data With ConnectionString
Call loRS.Open(asSQL, sCONNECTION_STRING, adOpenForwardOnly, adLockReadOnly)
End If ' IsObject(oConn)
' If errors occured
If Err Then
response.write "<HR color=red>" & err.description & "<HR color=red>" & asSQL & "<HR
color=red>"
' Clear the Error
Err.Clear
' If the recorset is open
If loRS.State = adStateOpen Then
' Close the recorset
loRS.Close
End If ' loRS.State = adStateOpen
' Release Recordset from memory
Set loRS = Nothing
' Return negative results
SetData = False
' Exit Routine
Exit Function
End If ' Err
' Return positve results
SetData = True
' If data was found
If Not loRS.EOF Then
' Pull data into an array
avDataAry = loRS.GetRows
End If ' Not loRS.EOF
' Close Recordset
loRS.Close
' Release object from memory
Set loRS = Nothing
End Function ' SetData
'---------------------------------------
' ----------------------------------------
'
' SQL Preperations are used to prepare v
' ariables for SQL Queries. If
' invalid data is passed to these routin
' es, NULL values or Default Data
' is returned to keep your SQL Queries f
' rom breaking from users breaking
' datatype rules.
'---------------------------------------
' ----------------------------------------
'
Public Function SQLPrep_s(ByVal asExpression, ByRef anMaxLength)
' If maximum length is defined
If anMaxLength > 0 Then
' Trim expression To maximum length
asExpression = Left(asExpression, anMaxLength)
End If ' anMaxLength > 0
' Double quote SQL quote characters
asExpression = Replace(asExpression, "'", "'")
' If Expression is Empty
If asExpression = "" Then
' Return a NULL value
SQLPrep_s = "NULL"
' Else expression is Not empty
Else
' Return quoted expression
SQLPrep_s = "'" & asExpression & "'"
End If ' asExpression
End Function ' SQLPrep_s
'---------------------------------------
' ----------------------------------------
'
Public Function SQLPrep_n(ByVal anExpression)
' If expression numeric
If IsNumeric(anExpression) And Not anExpression = "" Then
' Return number
SQLPrep_n = anExpression
' Else expression Not numeric
Else
' Return NULL
SQLPrep_n = "NULL"
End If ' IsNumeric(anExpression) And Not anExpression = ""
End Function ' SQLPrep_n
'---------------------------------------
' ----------------------------------------
'
Public Function SQLPrep_b(ByVal abExpression, ByRef abDefault)
' Declare Database Constants
Const lbTRUE = -1 '1 = SQL, -1 = Access
Const lbFALSE = 0
Dim lbResult ' Result To be passed back
' Prepare For any errors that may occur
On Error Resume Next
' If expression Not provided
If abExpression = "" Then
' Set expression To default value
abExpression = abDefault
End If ' abExpression = ""
' Attempt To convert expression
lbResult = CBool(abExpression)
' If Err Occured
If Err Then
' Clear the Error
Err.Clear
' Determine action based on Expression
Select Case LCase(abExpression)
' True expressions
Case "yes", "on", "true", "-1", "1"
lbResult = True
' False expressions
Case "no", "off", "false", "0"
lbResult = False
' Unknown expression
Case Else
lbResult = abDefault
End Select ' LCase(abExpression)
End If ' Err
' If result is True
If lbResult Then
' Return True
SQLPrep_b = lbTRUE
' Else Result is False
Else
' Return False
SQLPrep_b = lbFALSE
End If ' lbResult
End Function ' SQLPrep_b
'---------------------------------------
' ----------------------------------------
'
Public Function SQLPrep_d(ByRef adExpression)
' If Expression valid Date
If IsDate(adExpression) Then
' Return Date
'SQLPrep_d = "'" & adExpression & "'" ' SQL Database
SQLPrep_d = "#" & adExpression & "#" ' Access Database
' Else Expression Not valid Date
Else
' Return NULL
SQLPrep_d = "NULL"
End If ' IsDate(adExpression)
End Function ' SQLPrep_d
'---------------------------------------
' ----------------------------------------
 
' Else the connection is closed
Else
' Set the ConnectionString
Call SetConnectionString(csConnectionString)
' If atempt To open connection succeeded
If DBConnOpen() Then
' Acquire data With connection object
Call loRS.Open(asSQL, oConn, adOpenForwardOnly, adLockReadOnly)
' Return connection object To closed state
Call DBConnClose()
End If ' DBConnOpen()
End If ' aoConn.State = adStateOpen
' Else active connection is the ConnectionString
Else
' Acquire data With ConnectionString
Call loRS.Open(asSQL, sCONNECTION_STRING, adOpenForwardOnly, adLockReadOnly)
End If ' IsObject(oConn)
' If errors occured
If Err Then
response.write "<HR color=red>" & err.description & "<HR color=red>" & asSQL & "<HR
color=red>"
' Clear the Error
Err.Clear
' If the recorset is open
If loRS.State = adStateOpen Then
' Close the recorset
loRS.Close
End If ' loRS.State = adStateOpen
' Release Recordset from memory
Set loRS = Nothing
' Return negative results
SetData = False
' Exit Routine
Exit Function
End If ' Err
' Return positve results
SetData = True
' If data was found
If Not loRS.EOF Then
' Pull data into an array
avDataAry = loRS.GetRows
End If ' Not loRS.EOF
' Close Recordset
loRS.Close
' Release object from memory
Set loRS = Nothing
End Function ' SetData
'---------------------------------------
' ----------------------------------------
'
' SQL Preperations are used to prepare v
' ariables for SQL Queries. If
' invalid data is passed to these routin
' es, NULL values or Default Data
' is returned to keep your SQL Queries f
' rom breaking from users breaking
' datatype rules.
'---------------------------------------
' ----------------------------------------
'
Public Function SQLPrep_s(ByVal asExpression, ByRef anMaxLength)
' If maximum length is defined
If anMaxLength > 0 Then
' Trim expression To maximum length
asExpression = Left(asExpression, anMaxLength)
End If ' anMaxLength > 0
' Double quote SQL quote characters
asExpression = Replace(asExpression, "'", "'")
' If Expression is Empty
If asExpression = "" Then
' Return a NULL value
SQLPrep_s = "NULL"
' Else expression is Not empty
Else
' Return quoted expression
SQLPrep_s = "'" & asExpression & "'"
End If ' asExpression
End Function ' SQLPrep_s
'---------------------------------------
' ----------------------------------------
'
Public Function SQLPrep_n(ByVal anExpression)
' If expression numeric
If IsNumeric(anExpression) And Not anExpression = "" Then
' Return number
SQLPrep_n = anExpression
' Else expression Not numeric
Else
' Return NULL
SQLPrep_n = "NULL"
End If ' IsNumeric(anExpression) And Not anExpression = ""
End Function ' SQLPrep_n
'---------------------------------------
' ----------------------------------------
'
Public Function SQLPrep_b(ByVal abExpression, ByRef abDefault)
' Declare Database Constants
Const lbTRUE = -1 '1 = SQL, -1 = Access
Const lbFALSE = 0
Dim lbResult ' Result To be passed back
' Prepare For any errors that may occur
On Error Resume Next
' If expression Not provided
If abExpression = "" Then
' Set expression To default value
abExpression = abDefault
End If ' abExpression = ""
' Attempt To convert expression
lbResult = CBool(abExpression)
' If Err Occured
If Err Then
' Clear the Error
Err.Clear
' Determine action based on Expression
Select Case LCase(abExpression)
' True expressions
Case "yes", "on", "true", "-1", "1"
lbResult = True
' False expressions
Case "no", "off", "false", "0"
lbResult = False
' Unknown expression
Case Else
lbResult = abDefault
End Select ' LCase(abExpression)
End If ' Err
' If result is True
If lbResult Then
' Return True
SQLPrep_b = lbTRUE
' Else Result is False
Else
' Return False
SQLPrep_b = lbFALSE
End If ' lbResult
End Function ' SQLPrep_b
'---------------------------------------
' ----------------------------------------
'
Public Function SQLPrep_d(ByRef adExpression)
' If Expression valid Date
If IsDate(adExpression) Then
' Return Date
'SQLPrep_d = "'" & adExpression & "'" ' SQL Database
SQLPrep_d = "#" & adExpression & "#" ' Access Database
' Else Expression Not valid Date
Else
' Return NULL
SQLPrep_d = "NULL"
End If ' IsDate(adExpression)
End Function ' SQLPrep_d
'---------------------------------------
' ----------------------------------------