Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to design software or add marathi font in C#.net & how to insert marathi font in mysql database.

What I have tried:

how to design software or add marathi font in C#.net & how to insert marathi font in mysql database.
Posted
Updated 30-Sep-16 21:59pm

1 solution

In a short: you need to create database which supports unicode characters[^]

Then you have to make some changes in your connection string:

  1. Treating Binary Blobs As UTF8[^]
  2. How to Make Unicode Available between C# and MySQL | Assemble Force[^]

Note: in both cases, a proper connection string option[^] must be respectively changed. For more details, follow the above links.

Warning: before you change anything in your database, create a backup!!!

Quote:
(...)
If you haven’t created the table, you can create one with the following statement.

SQL
CREATE TABLE IF NOT EXISTS  (ID BIGINT NOT NULL PRIMARY KEY) ENGINE=MyIASM  DEFAULT CHRACTER SET=utf8 COLLATE utf8_general_ci;


This statement will create a table with utf8 encoding and utf8_general_ci as COLLATE.

If you want to change the table to support utf8, you can follow the syntax below.

SQL
ALTER TABLE _table_name_ CHARACTER SET=UTF8 COLLATE=utf8_general_ci;


Connect to MySQL in C#



There are two point you must follow in order to connect to MySQL and access Unicode. The first step is to open the connection with "Charset=utf8", and the second step is to run the command with the connection "set names utf8". And the encoding is case sensitive, so you mustn’t write it like "UTF8" or "utf-8".

C#
string conn_str = "server=202.117.15.72;uid=username;pwd=password;database=wordbase;Charset=utf8;";
// some other codes…
MySqlConnection conn = new MySqlConnection(connstr);
conn.Open();
MySqlCommand command = new MySqlCommand();
command.Connection = conn;
command.CommandText = "set names utf8";
command.ExecuteNonQuery();


With the steps done above, you can access MySQL with Unicode freely.
(...)

 
Share this answer
 
v5
Comments
Karthik_Mahalingam 1-Oct-16 5:18am    
5
Maciej Los 1-Oct-16 15:07pm    
Thank you, Karthik.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900