1
Reply

Wildcard Searching

travis.hurst

travis.hurst

Oct 15 2004 10:14 AM
2.9k
Hello, I am trying to add wildcard searching facilities to my search screen. I want to use % for searching on forname and surname. eg Bra% UPPER (FORENAME) LIKE 'BRA%' - Bradley - Bradshaw but also %MAD% -- Maddison -- Lomad Below is my existing search method ========================== private string BuildSearchSQL() { string strSQL; string strSQLSelect; string strSQLFrom; string strSQLWhere; strSQLSelect = "SELECT p.id, p.title, p.forename, p.surname, bu.unit_name, l.location, t.team_name "; strSQLFrom = "FROM PERSON p, VEC_BUSINESSUNIT bu, VEC_LOCATION l, VEC_TEAM t "; strSQLWhere = "WHERE p.BUSINESSUNITID = bu.ID(+) "; strSQLWhere += "AND p.LOCATIONID = l.ID(+) "; strSQLWhere += "AND p.TEAMID = t.ID(+) "; if (cboTitle.Text.Length != 0) strSQLWhere += "AND p.TITLE = '" + cboTitle.Text + "' "; if (txtForename.Text.Length != 0) strSQLWhere += "AND UPPER(p.FORENAME) = '" + txtForename.Text.ToUpper() + "' "; if (txtSurname.Text.Length != 0) strSQLWhere += "AND UPPER(p.SURNAME) = '" + txtSurname.Text.ToUpper() + "' "; if (cboBusUnit.Text.Length != 0) strSQLWhere += "AND UPPER(bu.unit_name) = '" + cboBusUnit.Text.ToUpper() + "' "; if (cboLocation.Text.Length != 0) strSQLWhere += "AND UPPER(l.location) = '" + cboLocation.Text.ToUpper() + "' "; if (cboTeam.Text.Length != 0) strSQLWhere += "AND UPPER(t.team_name) = '" + cboTeam.Text.ToUpper() + "' "; strSQL = strSQLSelect + strSQLFrom + strSQLWhere; return (strSQL); }

Answers (1)
Next Recommended Forum