ado.net 讀取mysql, Unable to convert MySQL date/time value to System.DateTime 錯誤

mysql中datetime的缺省值會設定爲0000-00-00/0000-00-00 00:00:00,.net中是0001-00-00/0000-00-00 00:00:00,

因此當.net試圖轉換時候會出現異常。


解決辦法:

在mysql connectionstring中添加選項:Convert Zero Datetime=True;  並且移除 Allow Zero Datetime=True;選項

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章