I've got a problem with searching for record(s) that match the staffID in my "Staff" table in the database. I have a string named mstrSql, a txtStaffID text box and a sql statement that goes
mstrSql = "Select * from Staff where staffID like '" & txtStaffID.Text.Trim() & "%" & "'"
I ran the code and it returned an error: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'like'. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
I've also tried
mstrSql = "Select * from Staff where staffID like '%" & txtStaffID.Text.Trim() & "%'"
That didn't work either. Can someone please provide me a correct syntax to run the above? Thanks.