Hello everyone,
I am new to VBScript. I need some help w/wildcarding. I have the following piece of code:
********************************************************
sEmpTitle = formatForSQL( Request.Form("EmpTitle") )
If Not sManagerName = "" Then
AppendAndClause
m_sWhereClause = m_sWhereClause & "E.EmpTitle"
AppendLikeOrEqualClause sEmpTitle
m_sWhereClause = m_sWhereClause & " '" & sEmpTitle & "' "
End If
*******************************************************
The AppendAndClause Function is just appending the 'AND' and the AppendLikeOrEqualClause is below:
*******************************************************
Private Function AppendLikeOrEqualClause( sString )
If InStr( 1, sString, WILDCARD_CHAR ) > 0 Then Call AppendLikeClause()
Else
Call AppendEqualClause()
End If
End Function
*********************************************************
Currently if someone searches and puts in an * (wildcard), it will append the "LIKE" condition but if someone puts in anything else like 't', 'jo', 'q', it won't append the "LIKE" clause but the "AND" clause instead - therefore I can't search by wildcarding. Can someone please help me rewrite the function above so that it will check based on wildcard?
Thanks for your help...
I am new to VBScript. I need some help w/wildcarding. I have the following piece of code:
********************************************************
sEmpTitle = formatForSQL( Request.Form("EmpTitle") )
If Not sManagerName = "" Then
AppendAndClause
m_sWhereClause = m_sWhereClause & "E.EmpTitle"
AppendLikeOrEqualClause sEmpTitle
m_sWhereClause = m_sWhereClause & " '" & sEmpTitle & "' "
End If
*******************************************************
The AppendAndClause Function is just appending the 'AND' and the AppendLikeOrEqualClause is below:
*******************************************************
Private Function AppendLikeOrEqualClause( sString )
If InStr( 1, sString, WILDCARD_CHAR ) > 0 Then Call AppendLikeClause()
Else
Call AppendEqualClause()
End If
End Function
*********************************************************
Currently if someone searches and puts in an * (wildcard), it will append the "LIKE" condition but if someone puts in anything else like 't', 'jo', 'q', it won't append the "LIKE" clause but the "AND" clause instead - therefore I can't search by wildcarding. Can someone please help me rewrite the function above so that it will check based on wildcard?
Thanks for your help...