开发者

Mysql Connector .Net: FormatException when trying to execute a command with parameters.

开发者 https://www.devze.com 2023-03-24 00:17 出处:网络
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:

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

精彩评论

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