有几年没用过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. crontab服务详解(任务计划)

    crontab是一个很方便的在unix/linux系统上定时(循环)执行某个任务的程序使用cron服务,用 service crond status 查看 cron服务状态,如果没有启动则 servi ...

  2. 免费提供UG、ProE二次开发、定制化开发服务

    免费提供UG.ProE二次开发,定制开发服务. 拥有六年UG.ProE二次开发经验,相关项目经验. 从事过智能设计.计算机图形学相关研究. 联系方式: QQ:1787326383 微信号:begtos ...

  3. Unable to create Azure Mobile Service: Error 500

    I had to go into my existing azure sql database server and under the configuration tab select " ...

  4. Eclipse下的Maven

    本文转载自:http://www.cnblogs.com/zlslch/p/5882567.html 当我们无法从本地仓库找到需要的构件的时候,就会从远程仓库下载构件至本地仓库.一般地,对于每个人来说 ...

  5. HDU2896 病毒侵袭

    题目大意:给出若干病毒的特征码,不超过500个.每个病毒的特征码长度在20~200之间.现在有若干网站的源代码,要检测网站的源代码中是否包含病毒.网站的个数不超过1000个,每个网站的源代码长度在70 ...

  6. PBR实现2.0

    之前的错误和欠缺 1. 过于简单的划分diffuse和specular,非常光滑的非金属材料也是很能反光的2. 费奈尔效应的处理,F0的选取也比较随意3. 没有GI,更不支持AO 正确划分diffus ...

  7. i2c 读写

    在I2C设备读取,必须是在同一个周期内. 一个例子,可以同时读出两个值 int read_register_double_value(int reg_addr, unsigned char *valu ...

  8. javascript网址收集

    1.模块的写法http://www.ruanyifeng.com/blog/2012/10/javascript_module.html 2.模块规范 AMDhttp://www.ruanyifeng ...

  9. 每天一个 Linux 命令(14):head 命令

    head 与 tail 就像它的名字一样的浅显易懂,它是用来显示开头或结尾某个数量的文字区块,head 用来显示档案的开头至标准输出中,而 tail 想当然尔就是看档案的结尾. 1.命令格式: hea ...

  10. 解决Android SDK下载和更新失败的方法(Win系统) 和离线安装

    http://jingyan.baidu.com/article/a3a3f811f370558da2eb8a94.html http://jingyan.baidu.com/article/636f ...