E
Eirik Eldorsen
I'm trying to use parameters in a search, but I can't get it right.
Before I add parameters this works:
string cmd =
"SELECT * " +
"FROM MyTable" +
"WHERE Title LIKE '%" + keyword + "%'
Here my code with parameters that don't work:
string cmd =
"SELECT * " +
"FROM MyTable " +
"WHERE Title LIKE '%@Keyword%'";
command.CommandText = cmd;
command.Parameters.Add(new SqlParameter("@Keyword", keyword))
What am I doinig wrong?
Before I add parameters this works:
string cmd =
"SELECT * " +
"FROM MyTable" +
"WHERE Title LIKE '%" + keyword + "%'
Here my code with parameters that don't work:
string cmd =
"SELECT * " +
"FROM MyTable " +
"WHERE Title LIKE '%@Keyword%'";
command.CommandText = cmd;
command.Parameters.Add(new SqlParameter("@Keyword", keyword))
What am I doinig wrong?