当区域性为“时,如何将Windows窗体中的日期保存到SQL Server”;ar KW“;

当区域性为“时,如何将Windows窗体中的日期保存到SQL Server”;ar KW“;,sql,vb.net,sql-server-2008,Sql,Vb.net,Sql Server 2008,我有多语言应用程序,其中我使用“en-US”和“ar-KW”语言。 我还有WinForm,我在其中使用DateTimePicker控件。 当用户登录时,如果其默认语言为“en-US”,则会保存记录,但当用户使用默认语言“ar-KW”时,则此日期格式不会保存在数据库中,并产生错误。为什么? 在SQL Server中,员工DateOfBirth字段的数据类型为smallDateTime。 我在VB中使用以下代码来保存记录。后端有一个正常的INSERT存储过程 If Me.dtDateOfBirth.

我有多语言应用程序,其中我使用“en-US”和“ar-KW”语言。 我还有WinForm,我在其中使用DateTimePicker控件。 当用户登录时,如果其默认语言为“en-US”,则会保存记录,但当用户使用默认语言“ar-KW”时,则此日期格式不会保存在数据库中,并产生错误。为什么?

在SQL Server中,员工DateOfBirth字段的数据类型为
smallDateTime
。 我在VB中使用以下代码来保存记录。后端有一个正常的
INSERT
存储过程

If Me.dtDateOfBirth.Checked = False Then
            cmd.Parameters.Add("@DateOfBirth", SqlDbType.SmallDateTime).Value = SqlDateTime.Null
Else
        If mUserDefaultLanguage = "ar-KW" Then
                Me.dtDateOfBirth.Format = DateTimePickerFormat.Custom
                Me.dtDateOfBirth.CustomFormat = "dd/MM/yyyy"
                Dim oDate As String = Me.dtDateOfBirth.Text
                Dim dt As Date
                dt = (CType(oDate, Date))
                cmd.Parameters.Add("@DateOfBirth", SqlDbType.DateTime).Value = SqlDateTime.Parse(dt)
        Else
                cmd.Parameters.Add("@DateOfBirth", SqlDbType.DateTime).Value = SqlDateTime.Parse(Me.dtDateOfBirth.Text)
        End If

End If

这可能是日期时间转换的问题:

    Dim oDate As String = Me.dtDateOfBirth.Text
    Dim dt As Date
    dt = (CType(oDate, Date))

为什么不使用
DateTimePicker
控件的
.Value
属性,而不是将其
.Text
属性转换为
DateTime
类型?

错误号:5 System.Data.SqlClient.SqlException:at System.Data.SqlClient.SqlConnection.OnError(SqlException异常,布尔连接)System.Data.SqlClient.SqlComman.InternalExecuteNonQuery(dbAsync Result Result,STring methodName,Boolean senToPipe)位于System.Data.SqlClient.SqlComman.ExecuteNonQuery()好东西在SqlException的
.Errors
属性中。捕捉到这一点-我打赌它会把问题弄清楚。即使我将SQL Server 2008中的数据类型更改为DateTime,然后是DateTime2(7),它也不会显示任何特定的错误详细信息,但仍然是相同的错误……….当我使用culuture“en-US”保存时,它会保存日期,但当我尝试使用“ar-KW”保存时它给出了错误。
错误中有什么内容吗?