I use a query to search for keywords in a specific field, when I put @parameter and then add a parameter with a value that it doesn’t work, however, when I enter the value directly, it works, anyone can help me pass the value as a parameter to my request , you are welcome? Below are my codes:
This works and retrieves any entry with the word "My" in its name.
string cmdText = "SELECT * FROM tblshareknowledge where title LIKE '%My%'";
cmd = new MySqlCommand(cmdText, con);
//cmd.Parameters.AddWithValue("@myTitle", title);
This does not work:
string cmdText = "SELECT * FROM tblshareknowledge where title LIKE '@myTitle'";
cmd = new MySqlCommand(cmdText, con);
cmd.Parameters.AddWithValue("@myTitle", title);
source
share