Description:
If you use a semicolon inside a string value to update / insert records,
the query fails. As far as I read from the MySQL manual semicolon ';' is
not a special character, and same query works just fine in MySQL Query
or MySQL client.
How to repeat:
using System;
using MySql.Data.MySqlClient;
namespace MySQLTest
{
class clsMySQLTest
{
[STAThread]
static void Main(string[] args)
{
string SQL;
MySqlConnection Connection=new MySqlConnection("Username=####;Password=####;Port=3306;Host=localhost;Database=test");
MySqlCommand Command;
Connection.Open();
SQL="CREATE TABLE IF NOT EXISTS test_semicolon (c VARCHAR(3))";
Command=new MySqlCommand(SQL,Connection);
Command.ExecuteNonQuery();
// This query fails, sometimes with no errors, but it doesn't insert any record
SQL="INSERT INTO test_semicolon(c) VALUES('1;')";
Command.ExecuteNonQuery();
MySqlDataReader Rows;
SQL="SELECT c FROM test_semicolon";
Rows=Command.ExecuteReader();
while (Rows.Read())
{
Console.WriteLine("Value : {0}",Rows.GetString(0));
}
}
}
}