c# MySQL like query not taking parameters

后端 未结 1 706
被撕碎了的回忆
被撕碎了的回忆 2021-01-13 08:52

I am using a query to find keywords in a particular field, when i put the @parameter and then addparameter with value it does not work, however when i input the value direct

相关标签:
1条回答
  • 2021-01-13 09:17

    You're currently putting your parameter within quotes, which means it's no longer being used as a parameter. I suspect you want:

    string cmdText = "SELECT * FROM tblshareknowledge where title LIKE @myTitle";
    cmd = new MySqlCommand(cmdText, con);
    cmd.Parameters.AddWithValue("@myTitle", "%" + title + "%");
    
    0 讨论(0)
提交回复
热议问题