Unable to convert MySQL datetime value to System.DateTime 解决方案
来源:互联网 发布:centos6.5 yum安装 编辑:程序博客网 时间:2024/05/18 11:48
这个问题发生在MySQL数据里面有Date类型数据,在C#中查询出来时候时间的类型不一致而导致!
网上看了一下,找到有两种解决方案:
1、在连接字符串中加入“Allow Zero Datetime=True”;
con = new MySqlConnection("server=localhost;database=test;CharSet=gb2312;pooling=false;port=3306;UId=root;Pwd=pwd;Allow Zero Datetime=True");
这个是一劳永逸、未雨绸缪的办法,加完就不用管了。
2、在用到有查询数据的语句时候加上 CAST(date as char) 转换一下:
eg(例如) : select CAST(字段名 as char) from tbl_tes
本内容来自于百度文库:http://wenku.baidu.com/link?url=kC8ALIPsgJX7KZELSls2Nd2dABtzNWMCWf5M_aULFhhGdWSO3sVc2yO9t1Fn4Pj_c7F9aa4z31Ur2zxikfiLvwD3RYf2yQXrN1uyh0Bl5ru
0 0
- Unable to convert MySQL datetime value to System.DateTime 解决方案
- Unable to convert MySQL date/time value to System.DateTime
- Unable to convert MySQL date/time value to System.DateTime
- Unable to convert MySQL date/time value to System.DateTime
- Unable to convert MySQL date/time value to System.DateTime
- Unable to convert MySQL date/time value to System.DateTime
- Unable to convert MySQL date/time value to System.DateTime
- Unable to convert MySQL date/time value to System.DateTime
- mysql c# Unable to convert MySQL date/time value to System.DateTime 错误
- ado.net 读取mysql, Unable to convert MySQL date/time value to System.DateTime 错误
- 解决 "unable to convert MySQL date/time value to System.DateTime"
- 项目--Unable to convert MySQL date/time value to System.DateTime
- 【YMGJ 2】时间格式转换:Unable to convert MySQL date/time value to System.DateTime
- Unable to convert MySQL date/time value to System.DateTime 错误
- ASP.net访问mysql数据库时发生Unable to convert MySQL date/time value to System.DateTime错误
- unable to convert MySQL date/time value to System.DateTime
- cannot implicitly convert type System.DateTime? to System.DateTime.
- Convert YYYYMMDD string date to a datetime value
- 【解答】智能对话机器人demo问题:ArrayList删除remove出现的只删除了一半
- #偷懒系列#概统:组合数概率相关
- JDBC-Java数据库连接
- hive启动报错 java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7B
- 分享C++11代码片段-tuple和chrono
- Unable to convert MySQL datetime value to System.DateTime 解决方案
- 解决ecplise提示需要移除@Override的问题
- 面向对象的设计模式(二)——Decorator模式
- 解决Android Studio 导入外部项目时报错:Could not find method android() for arguments
- UVALive 5695 -The Last Puzzle -区间dp
- delegate() 方法
- MAC Apache 启动 停止 重启命令
- web学习(2)--别踩白块儿(js版)(web入门)
- 王播求钟情中国美女护士,身体反应把他出卖了