cactus1000
Programmer
I have an SQL statement that searches for names in a directory. The names are passed through a variable called "strFacStaffName".
The problem is that we have an employee named "'Connor".
Naturally, the "'" causes an error message, so I tried to use URLEncode. The error message is gone, but the search returns no results.
Here's the code:
dim strFacStaffName
strFacStaffName = Server.URLEncode(Request.Form("FacStaffName"
)
cmdTmp.ActiveConnection = objdc
cmdtmp.CommandText = "SELECT Fullname, Title, Department, Phone, Fax, Email, Building, Office FROM Table1 WHERE Fullname2 LIKE '" & strFacStaffName & "%' OR fullname3 LIKE '" & strFacStaffName & "%' OR fullname4 LIKE '" & strFacStaffName & "%' OR fullname5 LIKE '" & strFacStaffName & "%' OR fullname6 LIKE '" & strFacStaffName & "%' Order By Lastname ;"
objrs.Open cmdTmp,,1,3
What exactly is replacing the "'"? What I need is for "O'Connor" to become "Oconnor".
The problem is that we have an employee named "'Connor".
Naturally, the "'" causes an error message, so I tried to use URLEncode. The error message is gone, but the search returns no results.
Here's the code:
dim strFacStaffName
strFacStaffName = Server.URLEncode(Request.Form("FacStaffName"
cmdTmp.ActiveConnection = objdc
cmdtmp.CommandText = "SELECT Fullname, Title, Department, Phone, Fax, Email, Building, Office FROM Table1 WHERE Fullname2 LIKE '" & strFacStaffName & "%' OR fullname3 LIKE '" & strFacStaffName & "%' OR fullname4 LIKE '" & strFacStaffName & "%' OR fullname5 LIKE '" & strFacStaffName & "%' OR fullname6 LIKE '" & strFacStaffName & "%' Order By Lastname ;"
objrs.Open cmdTmp,,1,3
What exactly is replacing the "'"? What I need is for "O'Connor" to become "Oconnor".