在Toad for MySQL中执行SELECT语句时出错 [英] Getting Error while executing SELECT statement in Toad for MySQL

查看:324
本文介绍了在Toad for MySQL中执行SELECT语句时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Toad

 MySql.Data.Types.MySqlConversionException
 Unable to convert MySQL date/time value to System.DateTime


推荐答案

这可能意味着这两个常见问题之一:

That could mean one of these two common issues:

1)零日期,在MySQL中为0000-00-00。 MySQL允许您存储它们以标记0个日期,甚至可以使用0001-01-01,但并不是所有的驱动程序或下游程序都可以处理它们。添加到连接字符串

1) Zero dates, which are 0000-00-00 in MySQL. MySQL allows you to store them to mark 0 dates, you can even use 0001-01-01, but not all drivers or downstream programs can handle them. Add to the connection string

Allow Zero Datetime=true;

另一个选择是明确删除它们,像

The other choice is explicitly removing them, something like

SELECT IF(DateCol='0000-00-00' OR DateCol<'1970-01-01', NULL, DateCol) as DateCol,
      Othercol1, ID ....
FROM TBL

2)日期格式。对于某些驱动程序/程序组合,日期将作为字符串处理。显式转换是必需的:

2) Date formatting. For some driver/program combination, the dates are handled as strings. Explicit conversion is necessary:

SELECT DATE_FORMAT(DateCol, '%m/%d/%Y') as DateCol,
      Othercol1, ID ....
FROM TBL

这篇关于在Toad for MySQL中执行SELECT语句时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆