hi
i am working with an application where i have to enter dob in textbox in the format "dd\MM\yyyy".what i have done yet is as below:

 Private Sub txtDOB_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDOB.LostFocus
        If IsDate(txtDOB.Text) = True Then
            MsgBox("correct date")
        Else
            MsgBox("input correct date")
        End If
    End Sub

Now problem is that when i save this date to the sqlserver it just saved in the wrong format "MM\dd\yyyy".
My computer date format is also dd\MM\yyyy.
i am saving date using this code:

Dim sqlinsert As String
                sqlinsert = "INSERT INTO C_tab(FirstName,dob,phone,email)" & _
                "VALUES( @FirstName,@dob,@phone,@email)"
Dim cmd As New SqlCommand(sqlinsert, con)
cmd.Parameters.Add(New SqlParameter("@FirstName", UCase(txtFirstname.Text)))
cmd.Parameters.Add(New SqlParameter("@dob", txtDOB.Text))
cmd.Parameters.Add(New SqlParameter("@phone", txtcontactno.Text))
cmd.Parameters.Add(New SqlParameter("@email", txtemail.Text))
cmd.ExecuteNonQuery()
cmd.Dispose()

What i want is that user must entered date in correct format which i given and also that date must be save in the sqlserver database in the same format.

Try using a forward slash "/" instead of a backward slash "\" as the date field separator.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.