Description:
Hi,
I used mysql connector 5.2.5 and mysql server 5.1 in my c# project.
Im using latin5 charset, also l have setup mysql server default charset latin5.
l dont have problem with Turkish Character Set but when l have used € symbol in queries shown like ? ,
l have written sample code below please look at.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySql.Data.MySqlClient;
namespace Sample
{
class Program
{
static void Main(string[] args)
{
MySqlConnection connection = new MySqlConnection();
connection.ConnectionString =
"server=localhost;user id=root;password=****;persist security info=True;database=new_db;Character Set=latin5";
connection.Open();
MySqlCommand command = new MySqlCommand();
command.Connection = connection;
command.CommandType = CommandType.Text;
command.CommandText = @"
DROP TABLE IF EXISTS table_test;
CREATE TABLE table_test(
colid INT (11) NOT NULL AUTO_INCREMENT,
colname VARCHAR (150) NOT NULL,
PRIMARY KEY (colid)
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET latin5
COLLATE latin5_turkish_ci;";
command.ExecuteNonQuery();
Console.WriteLine("Executed : {0}\r\n", command.CommandText);
// using turkish characters and € symbol
command.CommandText = @"INSERT INTO table_test VALUES (NULL, 'şüçğı'), (NULL, '€')";
command.ExecuteNonQuery();
Console.WriteLine("Executed : {0}\r\n", command.CommandText);
// reading data
command.CommandText = "SELECT `colid`, `colname` FROM table_test";
MySqlDataReader reader = command.ExecuteReader();
try
{
if (reader.HasRows)
while (reader.Read())
Console.WriteLine(String.Format("Row {0} - {1}", reader.GetInt32(0), reader.GetString(1)));
}
finally
{
if (!reader.IsClosed)
reader.Close();
}
}
}
}
Here Outputs
Executed :
DROP TABLE IF EXISTS table_test;
CREATE TABLE table_test(
colid INT (11) NOT NULL AUTO_INCREMENT,
colname VARCHAR (150) NOT NULL,
PRIMARY KEY (colid)
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET latin5
COLLATE latin5_turkish_ci;
Executed : INSERT INTO table_test VALUES (NULL, 'şüçğı'), (NULL, '?')
Row 1 - şüçğı
Row 2 - ?
Turkish characters are ok but € symbol is not
Thank you very much now
Regards
How to repeat:
Please send solution my email adress