Am developing a tamil
website using ASP.NET MVC
and MYSQL
.
While updating the values (tamil language text) from ASP.NET MVC website to Database all my values as storing as format like this ??????????????
When I directly run the insert query into my database I am able to insert the tamil text into the database.
Asp.NET MVC : I have the below code
<meta charset="utf-8" />
MySQL - Create table syntax :
CREATE TABLE IF NOT EXISTS `Login` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`username` text COLLATE utf8_unicode_ci,
`password` mediumtext COLLATE utf8_unicode_ci,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ;
Note: I have been using the Entity Framework
to connect with the MySQL database.
Is any thing missing from my side?
From Comment
Solution Found - just add ";Charset=utf8"
to connection string.
Here is the working solution:
<add name="photostorageEntities"
connectionString="metadata=res://*/Models.Photos.csdl|
res://*/Models.Photos.ssdl|res://*/Models.Photos.msl;
provider=MySql.Data.MySqlClient;
provider connection string="server=ServerIP;
User Id=UID;password=PASS;
Persist Security Info=True;database=photostorage; Charset=utf8""
providerName="System.Data.EntityClient" />
Thanks everyone! :)
I also faced the exact same problem.
Add this connection property
to the jdbc
driver where you are defining the database connection.
<property name="connectionProperties" value="characterEncoding=UTF-8;characterSetResults=UTF-8"/>
I hope this will solve your problem.
Use following query to set the default character set to already created table
ALTER TABLE Login CONVERT TO CHARACTER SET utf8;
You are using collate in multiple places. The following will be enough
CREATE TABLE IF NOT EXISTS `Login` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`username` text,
`password` mediumtext,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With