Error using a wildcard in a SQL search
Posted on 2005-04-22
I have a text box that takes input from a user and I want to use that information to do a SQL search. I am searching on last name and I would like them to be able to do a partial search.
My current SQL statement is:
SELECT DISTINCT str_agent_number, str_agent_fname, str_agent_lname, num_agent_code, str_location_code, num_mbc_code, num_territory_number, str_address, str_city, str_zip, str_phone_number, str_state FROM tbl_sro_boatdeck INNER JOIN tbl_state_code_lookup ON tbl_sro_boatdeck.num_state_code = tbl_state_code_lookup.num_state_code WHERE tbl_sro_boatdeck.str_agent_lname LIKE '" & txtLName.Text & "'"
When I put a % sign on either side of 'txtLName.Text' I receive an invalid character error. Please advise. thanks.