开发者

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 '?'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜