%
'==========================================================
'Livinguptown.com Application Functions
' Online Engineering ©2007, All Rights Reserved.
'Developer Info:
' Online Engineering
' 718 N. Poplar Street #2A
' Charlotte, NC 28202
' http://www.onlinengineering.com
'
'Version: 1.0 - Date: 4/3/2007
'================================================================
'Name: appFunctions.asp
'Description: Contains all of the global functions used within
' the application. This includes functions for
' accessing the database.
'================================================================
Dim sql
Dim rcSet
Function cleanString(str)
cleanString = Replace(str,"'","''")
End Function 'cleanString
Function strEmpty(str)
strEmpty = False
If str = "" OR IsNull(str) Then strEmpty = True
End Function 'strEmpty
Function strParam(strTestValue,strDefaultValue)
strParam = strTestValue
If strEmpty(strParam) Then strParam = strDefaultValue
End Function 'strParam
Function appOpenQuery(strSQL)
Set appOpenQuery = Server.CreateObject("ADODB.Recordset")
With appOpenQuery
.ActiveConnection = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:\hosting\Streetcarsub\_private\realestateDB.mdb;User ID=;Password=;"
.Source = strSQL
.CursorType = 3
.CursorLocation = 2
.LockType = 1
.Open()
End With
End Function 'appOpenQuery
'==================================================================================================================================
Function appExecuteQuery(strSQL)
Dim cmdExecute : Set cmdExecute = Server.CreateObject("ADODB.Command")
With cmdExecute
.ActiveConnection = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:\hosting\Streetcarsub\_private\realestateDB.mdb;User ID=;Password=;"
.CommandText = strSQL
.Execute()
.ActiveConnection.Close
End With
Set cmdExecute = Nothing
End Function 'appExecuteQuery
'==================================================================================================================================
Function appOpenQuerySQL(strSQL)
Set appOpenQuerySQL = Server.CreateObject("ADODB.Recordset")
With appOpenQuerySQL
.ActiveConnection = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:\hosting\Streetcarsub\_private\realestateDB.mdb;User ID=;Password=;"
.Source = strSQL
.CursorType = 3
.CursorLocation = 2
.LockType = 1
.Open()
End With
End Function 'appOpenQuery
'==================================================================================================================================
Function appExecuteQuerySQL(strSQL)
Dim cmdExecute : Set cmdExecute = Server.CreateObject("ADODB.Command")
With cmdExecute
.ActiveConnection = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:\hosting\Streetcarsub\_private\realestateDB.mdb;User ID=;Password=;"
.CommandText = strSQL
.Execute()
.ActiveConnection.Close
End With
Set cmdExecute = Nothing
End Function 'appExecuteQuery
'==================================================================================================================================
Sub appCloseRS(rs)
If IsObject(rs) Then
rs.Close
Set rs = Nothing
end if
End Sub 'closeRecordset
'======================================================Form Error Subroutine=======================================================
Sub formError(byRef errorVar,strErr)
If NOT IsArray(errorVar) Then
ReDim errorVar(0)
errorVar(0) = strErr
Else
ReDim Preserve errorVar(UBound(errorVar)+1)
errorVar(UBound(errorVar)) = strErr
End If
End Sub 'formError
'==================================================================================================================================
'====================================================Get Error Subroutine==========================================================
Function getError(errorVar,strErr)
Dim x
getError = False
If IsArray(errorVar) Then
For x = 0 to UBound(errorVar)
If LCase(errorVar(x)) = LCase(strErr) Then
getError = True
Exit Function
End If
Next
End If
End Function 'getError
'==================================================================================================================================
'====================================================setFieldLabel Subroutine======================================================
Function setFieldLabel(errorObject,strLabel,errorString)
If getError(errorObject,errorString) Then
setFieldLabel = "" & strLabel & " "
Else
setFieldLabel = strLabel
End If
End Function 'setFieldLabel
'==================================================================================================================================
Function ValidateEmail(str)
ValidateEmail = false
Dim regEx, retVal
Set regEx = New RegExp 'Create regular expression
regEx.Pattern = "^[a-z0-9][\!-\~]*\@[a-z\d\-\.]+\.[a-z]{2,4}(\.[a-z]{2})?$" 'Set pattern
regEx.IgnoreCase = true 'Set case sensitivity.
retVal = regEx.Test(str) 'Execute the search test.
If NOT retVal Then Exit Function
ValidateEmail = true
End Function
Function GetRandomizedSequencerArray(iArraySize)
Dim arrTemp()
Dim I
Dim iLowerBound, iUpperBound
Dim iRndNumber
Dim iTemp
' Set array size
ReDim arrTemp(iArraySize - 1)
' Init randomizer
Randomize
' Get bounds into local vars for speed
iLowerBound = LBound(arrTemp)
iUpperBound = UBound(arrTemp)
' Insert initial values
For I = iLowerBound To iUpperBound
arrTemp(I) = I
Next
' Loop through the array once, swapping each value
' with another in a random location within the array.
For I = iLowerBound to iUpperBound
' Generate random # in range
iRndNumber = Int(Rnd * (iUpperBound - iLowerBound + 1))
' Swap Ith element with iRndNumberth element
iTemp = arrTemp(I)
arrTemp(I) = arrTemp(iRndNumber)
arrTemp(iRndNumber) = iTemp
Next 'I
' Return our array
GetRandomizedSequencerArray = arrTemp
End Function
Function altRow(intRow)
altRow = "altRowOdd"
If intRow MOD 2 Then altRow = "altRowEven"
End Function
function RTESafe(strText)
'returns safe code for preloading in the RTE
dim tmpString
tmpString = trim(strText)
'convert all types of single quotes
tmpString = replace(tmpString, chr(145), chr(39))
tmpString = replace(tmpString, chr(146), chr(39))
tmpString = replace(tmpString, "'", "'")
'convert all types of double quotes
tmpString = replace(tmpString, chr(147), chr(34))
tmpString = replace(tmpString, chr(148), chr(34))
' tmpString = replace(tmpString, """", "\""")
'replace carriage returns & line feeds
tmpString = replace(tmpString, chr(10), " ")
tmpString = replace(tmpString, chr(13), " ")
RTESafe = tmpString
end function
%>
Charlotte NC Real Estate :: Deborah Cox :: Streetcar Suburbs
<%
Dim sqltext, rstext
sqltext = "SELECT homepage_ID, homepage_title, homepage_text FROM tbl_homepage"
Set rstext = appOpenQuery(sqltext)
Dim sqlFeatured, rsFeatured
sqlFeatured = "SELECT * FROM tbl_featured"
Set rsFeatured = appOpenQuery(sqlFeatured)
%>
©2008 StreetCarSuburbs.com