The code below seems not to be inserting the parameter value to the query (nothing is returned by the query). If I test that query in the DB (of course instead of the ?author parameter I type the passed value and some rows are returned. Why ?
var conn = new MySqlConnection(connectionString);
MySqlCommand comm = new MySqlCommand("", conn);
comm.Parameters.Add(new MySqlParameter("?author", author)); //I've also tried AddWithValue method
comm.CommandText = .....;
conn.Open();
MySqlDataReader myReader = comm.ExecuteReader();
try
{
while (myReader.Read())
{
//unreachable code because nothing is returned
}
}
catch
{
myReader.Close();
conn.Close();
categoriesList.Clear();
}
finally
{
myReader.Close();
conn.Close();
}
Since you are using
MySQLCommanddon’t add?in parameter’s name:if you have query like this:
then you have to do this this:
UPDATE
Assuming you have query with
LIKEcondition:then try this: