有几年没用过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. es6 ... 表达

    ... 包含0个或n个属性, { ...state.counters [id]: state.counters[id] - 1 } 只改变其中的id相对应的属性,其他保持不变

  2. RDLC An unexpected error occurred while compiling expressions. Native compiler return value: '-1073741511'

    One of my web project, which has a rdlc file using some expressions, was working fine while developi ...

  3. python getopt使用

    函数getopt(args, shortopts, longopts = []) 参数args一般是sys.argv[1:] shortopts 短格式 (-) longopts 长格式(--) 命令 ...

  4. 01从c到c++

    c++的发展历史  + 80年代贝尔实验室 本贾尼 + 83年 正式命名c++ + 87年 gnu制定了c++标准 + 92年 微软和IBM分别制定了c++标准 + 98年 ansi ISO 制定了标 ...

  5. 【学】React的学习之旅3 - 添加事件(onClick)

    button除了用<input type="button">之外,还可以直接用<button></button>来创建,而2个标签的中间的内容就 ...

  6. Caffe使用:如何将一维数据或其他非图像数据转换成lmdb

    caffe事儿真多,数据必须得lmdb或者leveldb什么的才行,如果数据是图片的话,那用caffe自带的convert_image.cpp就行,但如果不是图片,就得自己写程序了.我也不是计算机专业 ...

  7. require.js

    日期: 2012年11月 7日 http://www.ruanyifeng.com/blog/2012/11/require_js.html 这个系列的第一部分和第二部分,介绍了Javascript模 ...

  8. Mac 配置Charles抓https的包

    安装Charles 这个简单,略过... 打开Charles,在Menu选择Help > Install Charles CA SSL Certificate Keychain Access(钥 ...

  9. day9-paramiko

    一.基于用户名密码认证SSH连接 #!/usr/bin/env python #coding:utf8 import paramiko ssh = paramiko.SSHClient()#创建SSH ...

  10. Python体验(10)-图形界面之计算器

    import wx class Form(wx.Frame): def __init__( self, parent, id, title ): wx.Frame.__init__(self,pare ...