Bug #5922 Queries containing semicolons fail
Submitted: 6 Oct 2004 14:02 Modified: 9 Oct 2004 13:40
Reporter: Puiu Hrenciuc Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:1.0.0-Beta OS:Windows (Windows XP Pro SP2)
Assigned to: Assigned Account CPU Architecture:Any

[6 Oct 2004 14:02] Puiu Hrenciuc
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));
			}
		}
	}
}
[6 Oct 2004 14:19] Puiu Hrenciuc
Sorry this is a repeat of the bug with ID 5876