有几年没用过MySql数据了,今天在使用C#访问MySql数据库时出现了一个小插曲。

错误提示:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ???

当然,错误提示已经很明白的说明是sql的语法错误。

然而,我的sql 语句是 select count(*) from tableName,没有发现错误,之后进行单步调试,在调试的时候将从代码中执行的sql语句粘贴到mysql中执行,结果成功通过。

鉴于之前编程的经验,出现此处错误的最大可能就是我的sql语句中含有mysql的关键字,再回头看sql语句,语句中原本有的语句(select count(*) from)肯定是没问题,问题就出在我自己写的tableName上面,发现tableName中含有汉字,再百度,发现是字符编码不一致(???其实就是汉字没有显示出来),于是更改mysql安装目录下的my.ini文件,将该文件中default-character-set=latin1改为default-character-set=utf8(两处),之后重启mysql服务,再次运行程序,问题解决

C# Mysql You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ????的更多相关文章

  1. SQL语句报错:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near

    报错如图: 最开始其实我的列名tname和tsubject分别叫name和subject,后来看到网上有说这个报错可能是数据库建表的时候使用了mysql的关键词,我就只把name改了.后来还是这个问题 ...

  2. ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 7

    问题: 使用hibernate4.1.1,数据库使用mysql5.1.30,使用hibernate自动生成数据库表时,hibernate方言使用org.hibernate.dialect.MySQLI ...

  3. MySql 执行语句错误 Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

    关于用Power Designer 生成sql文件出现 错误  [Err] 1064 - You have an error in your SQL syntax; check the manual ...

  4. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '

    mysql中如果字段使用了关键字,在插入和更新时会提示 You have an error in your SQL syntax; check the manual that corresponds ...

  5. MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ...

    下面是我update数据库时打印出来的异常: ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSynt ...

  6. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%逸%'' at line 1

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-/ ...

  7. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server versio

    Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL ...

  8. 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'groups)VALUES('1','hh','hh@163.com','Boss')' at line 1

    mysql8.0版本 在已存在的表里插入一条数据 insert INTO api_user(id,username,email,groups)VALUES('1','hh','hh@163.com', ...

  9. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group t1,customer t2

    ### SQL: select t1.gid,t1.gname,t1.gvalue,t1.gtype, t1.gaddress,t1.gmembers, t1.gcode,t1.gphone, t2. ...

随机推荐

  1. mvc中Url.RouteUrl或者Html.RouteLink实现灵活超链接,使href的值随路由名称或配置的改变而改变[bubuko.com]

    mvc,超链接除了直接写在a标签的href内还可以使用路由规则来生成,这样在改变了路由规则或者路由名称时不用再去代码中更改href的值,而且还容易遗漏.借助Url.RouteUrl或者Html.Rou ...

  2. C#中的using关键字用法总结

    C#中的using关键字主要有两种用法: 1.using作为指令: (1)用于将命名空间引入当前单元,例如:using System.Windows.Forms; (2)为现有的命名空间创建一个别名, ...

  3. 启用vim-ruby的rails complete (macvim)

    macvim启用rails complete 用vim已经很久了, 一直用spf13也挺好的, 最近遇到要处理一个遗留项目, 数据库字段太多, 因此折腾了一下配置好vim的ruby-completio ...

  4. [MySQL] 号称永久解决了复制延迟问题的并行复制,MySQL5.7

    一.缘由: 某天看到主从复制延时的告警有点频繁,就想着是不是彻底可以解决一下. 一般主从复制,有三个线程参与,都是单线程:Binlog Dump(主) ----->IO Thread (从) - ...

  5. ERROR actor.OneForOneStrategy: org.apache.spark.SparkContext

    今天在用Spark把Kafka的数据往ES写的时候,代码一直报错,错误信息如下: 15/10/20 17:28:56 ERROR actor.OneForOneStrategy: org.apache ...

  6. sklearn学习笔记3

    Explaining Titanic hypothesis with decision trees decision trees are very simple yet powerful superv ...

  7. WindowsFormsHost使用问题

    WindowsFormsHost使用问题 WPF WindowsFormsHost 类 允许在 WPF 页面上承载 Windows Forms控件的元素. 命名空间:  System.Windows. ...

  8. mybatis一级缓存和二级缓存

    1.一级缓存:session级别 执行以下操作之后一级缓存消失: 1)执行了session.clearCache(); 2)执行了CUD操作后 3)执行了session.close() 2.二级缓存: ...

  9. json格式的日期格式化

    function formatterdate(val) { if (val != null) { var re = /-?\d+/; var m = re.exec(val); var date = ...

  10. 03-c#入门(简易存款利息计算器v1.0)

    本想把练习题做了的结果放上来,不过发现附录是有答案的,就算了吧,自己做了没问题就行了哈.之前提到过,要是有朋友有想法,需要做小工具我可以帮忙实现,不过貌似大家都很忙.SO,自己学完第4章后,决定做一个 ...