无法MySQL的日期/时间值转换为System.DateTime转换为、日期、时间、MySQL

2023-09-02 11:47:02 作者:我是配角还是局外人

我得到这个错误:

无法MySQL的日期/时间值转换为System.DateTime

Unable to convert MySQL date/time value to System.DateTime

当我试图从MySQL数据库获取数据。 我在日期数据类型在我的MySQL数据库。但是,当检索到我的数据表,它得到上述错误。

while I am trying to fetch the data from a MySQL database. I have the date datatype in my MySQL database. But while retrieving it into my datatable, it get the error above.

我该如何解决这个问题?

How can I fix this?

推荐答案

如果我谷歌无法MySQL的日期/时间值转换为System.DateTime我看到多次提及从Visual Studio访问MySQL的一个问题。那是你的背景?

If I google for "Unable to convert MySQL date/time value to System.DateTime" I see numerous references to a problem accessing MySQL from Visual Studio. Is that your context?

一个解决方案建议是:

这是不是一个错误,但预期   行为。请在手动   连接选项和设置允许零   日期时间为真,作为连接   图片和错误就会消失。

This is not a bug but expected behavior. Please check manual under connect options and set "Allow Zero Datetime" to true, as on attached pictures, and the error will go away.

参考: http://bugs.mysql.com/bug.php?id=26054