Mysql Connector .Net: FormatException when trying to execute a command with parameters.
I am using Mysql .Net Connector to access a database in C#. I get an FormatException when I try to execute a statement with parameter. Here is my code:
MySqlCommand comm = connection.CreateCommand();
comm.CommandText = "SELECT id_ FROM journalarticle WHERE title LIKE ?title";
comm.Parameters.Add("?title", DbType.AnsiString开发者_如何学编程).Value = title;
MySqlDataReader reader = comm.ExecuteReader();
while (reader.Read())
{
id = reader.GetInt32(0);
}
comm.Dispose();
reader.Dispose();
Isn't it an @ symbol not a '?'
精彩评论