從字元字串轉換成日期及/或時間時,轉換失敗 VB

由於出現上午下午不能進去資料庫
所以要指定字串格式

做個示範
Dim sdate As String = "2017 / 10 / 1 上午 12:00:00"
如果把sdate insert 進去Sql會失敗

Dim date_test As Date  '再宣告一個日期來存他
date_test = sdate
date_test.ToString("yyyy/MM/dd HH:mm:ss")

這樣 date_test insert 就OK了

留言

這個網誌中的熱門文章

VB 檢查數字

CheckBox GridView 動態產生