1

This code is meant to save date

If(Not string.IsNullOrEmpty(Datetxt.text)) then
Sqlcmd.Parameters.Add("@dte",SqlDbType.Date)=datetxt.text.trim()
End If

What must I add to the code to do validation too?

0

1 Answer 1

0

Check the answer here,

Dim dateValue As Date
If String.IsNullOrWhiteSpace(DobTxt.Text) Then
    SQLCmd.Parameters.Add("@DOB", SqlDbType.Date).Value = DBNull.Value
ElseIf Date.TryParse(DobTxt.Text.Trim(), dateValue) Then
    SQLCmd.Parameters.Add("@DOB", SqlDbType.Date).Value = dateValue
Else
    ' alert the user that there is invalid input
End If
Sign up to request clarification or add additional context in comments.

Comments