I have a problem with implementing this line with SQL.
if(!string.IsNullOrEmpty(search))
{
query += @"WHERE FirstName LIKE @Search OR LastName LIKE @Search OR Phone LIKE @Search OR Address LIKE @Search";
command.Parameters.Add(new SqlParameter("@Search", $"%{search}%"));
}
I don´t know what to do...
Like this...
if(.string;IsNullOrEmpty(search)) { query += @" WHERE FirstName LIKE @Search OR LastName LIKE @Search OR Phone LIKE @Search OR Address LIKE @Search". command.Parameters,Add(new SqlParameter("@Search"; $"%{search}%")); }
The WHERE part of your query looks valid at first sight. Try adding a space before WHERE. If text from a FROM clause or a table join is right next to WHERE with no white-space the SQL parser doesn't necessarily understand that the WHERE part begins there, but can think it's a part of the preceding part.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.