Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我得到这样的日期
DateTimePicker1.Value.Date.ToShortDateString()
并尝试插入我的数据库。
错误是:
从字符串转换日期和/或时间时转换失败。
昨天还在工作。今天我删除了表中的所有值,现在不工作了
看起来您的应用服务器和数据库服务器具有不同的区域日期设置。此外, DateTimePicker1.Value.Date 产生一个 DateTime ,您应该使用它将它添加到数据库中,而不必经历区域转换混乱。
使用以下方式获取您的日期:
CDate(DateTimePicker1.Value.Date.ToShortDateString())