Hello,
I am trying to compare the date in my textbox with the date in my database.
I am using the following code but I still get the error when the textbox containes a date and the databasefield contains null:
"Conversion from type 'DBNull' to type 'Date' is not valid."
What am I doing wrong???
I am trying to compare the date in my textbox with the date in my database.
I am using the following code but I still get the error when the textbox containes a date and the databasefield contains null:
"Conversion from type 'DBNull' to type 'Date' is not valid."
What am I doing wrong???
Code:
Public Function ThereAreChangesDatum(ByVal txtTextBox As System.Windows.Forms.TextBox, ByVal DataReader As SqlDataReader, ByVal DB_Veld As String, ByVal DB_Index As Integer) As Boolean
If txtTextBox.Text <> String.Empty And DataReader.IsDBNull(DB_Index) OrElse
(txtTextBox.Text <> String.Empty AndAlso CDate(txtTextBox.Text) <> CDate(DataReader(DB_Veld))) Then
Return True
ElseIf txtTextBox.Text = String.Empty And Not DataReader.IsDBNull(DB_Index) Then
Return True
Else
Return False
End If
End Function