我正在将日期字段传递给 SQL 数据库。
该字段在 VB.NET 应用程序中声明为 String。
我写了一段用于转换为 Date 的代码:
Dim dtBdate As Date
If param_strDOB <> String.Empty Then
dtBdate = Convert.ToDateTime(param_strDOB)
End If
但该值作为 #3/11/2011# 传递。它有一个 # - 在日期字段的两边签名。
我该如何解决?
在 SQL 数据库中,存储过程将输入参数作为“@DOB DateTime”。
请您参考如下方法:
来自 MSDN :
The date and time can be bracketed with a pair of leading and trailing NUMBER SIGN characters '#'
因此您应该能够按原样转换/解析。
