Luke
Luke

Reputation: 5971

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();

Upvotes: 0

Views: 329

Answers (1)

Paul C
Paul C

Reputation: 4776

Isn't it an @ symbol not a '?'

Upvotes: 2

Related Questions