本文介绍了将日期时间从VB6插入/更新到SQL服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MS ACCESS中

itmarr(0,0)=bill_date

itmarr(1,0)= TxtDate.Text



在SQL SERVER中

itmarr(0,0)=bill_date

itmarr(1,0)=格式(TxtDate.Text, dd MMM yyyy)



SQL SERVER中的错误显示]

将varchar数据类型转换为日期时间数据类型导致超出范围价值



我尝试过:



In MS ACCESS
itmarr(0, 0) = "bill_date"
itmarr(1, 0) = TxtDate.Text

IN SQL SERVER
itmarr(0, 0) = "bill_date"
itmarr(1, 0) = Format(TxtDate.Text, "dd MMM yyyy")

ERROR SHOW IN SQL SERVER]
the conversion of a varchar data type to a datetime data type resulted in an out-of-range value

What I have tried:

Insert/update datetime from VB6 to Sql Server

推荐答案

yy-MM-ddTHH24:mi:ss

yyyyMMdd HH24:mi:ss

同样值得阅读ISO标准的日期 - []



如果这不能解决您的具体问题,那么在

It's also worth having a read up on the ISO standard for dates - ISO 8601 - Wikipedia[^]

If this doesn't solve your specific problem, then put a breakpoint (F9) on the line

itmarr(1, 0) = Format(TxtDate.Text, "dd MMM yyyy")

并查看TxtDate的内容 - 您可能会发现它根本无法格式化为日期。您应该添加一些验证或使用DatePicker控件。

and have a look at the contents of TxtDate - you'll probably find that it can't be formatted as a date at all. You should really add some validation OR use a DatePicker control.


这篇关于将日期时间从VB6插入/更新到SQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 11:42