解决Mysql插入中文乱码问题:Incorrect string value: ‘xA8Dx
程序员文章站
2022-04-11 21:29:44
...
之前几次碰到插入数据库的时候提示 Incorrect string value: ‘\xA8D\xA8D\xBA\xE1…’ for column ‘content’ at row 1 一般都是插入中文的时候就提示了、 解决办法是, 在插入数据库之前 先执行一次mysql_qeury(“set names gbk”) 确定好字符编码, 还有
之前几次碰到插入数据库的时候提示 Incorrect string value: ‘\xA8D\xA8D\xBA\xE1…’ for column ‘content’ at row 1
一般都是插入中文的时候就提示了、
解决办法是, 在插入数据库之前 先执行一次mysql_qeury(“set names gbk”) 确定好字符编码,
还有可能要选择数据库校对码。
-----------------------------------------------------
C#代码:
MySQLConnection conn = new MySQLConnection("Data Source=testdb;Password=123456;User ID=root;Location=localhost;Port=3306;charset=gbk"); MySQLCommand cmdSet = new MySQLCommand("set names gbk", conn); MySQLCommand cmd = new MySQLCommand("INSERT INTO textTest(D_txt) VALUES ('" + textBox1.Text + "')", conn); conn.Open(); cmdSet.ExecuteNonQuery(); int result = (int)cmd.ExecuteNonQuery(); conn.Close(); MessageBox.Show(result.ToString());
推荐阅读
-
解决mysql不能插入中文Incorrect string value
-
JSP MySQL插入数据时出现中文乱码问题的解决方法
-
解决mysql不能插入中文Incorrect string value
-
mysql插入表数据中文乱码问题解决方案
-
php 解决MySQL插入数据出现 Incorrect string value: '\xF0\x9F\x92\x8BTi...'错误
-
mysql命令框中向表中插入中文字符,在可视化工具MySQL Workbeach或phpMyAdmin中不显示或显示乱码的问题解决
-
JSP MySQL插入数据时出现中文乱码问题的解决方法
-
MySql 中文写入数据库乱码及Incorrect string value: '\xF0\x9F...' for column 'XXX' at row 1解决
-
针对mysql数据库无法在表中插入中文字符的解决方案(彻底解决:java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x92\x94‘ )
-
mysql插入表数据中文乱码问题解决方案