IsDBNull problem
I am probably doing this wrong
If
IsDBNull(EDFRow.EStart)ThenMe.EStartDateTimePicker.Checked =FalseElseMe.EStartDateTimePicker.Checked =TrueEndIfI get the error that the filed is dbnull
Can someone please explain this.
Davids Learning
Are you saying that IsDBNull is returing true or that an error is being generated?
If its the later then post the exact error message.
What sort of object is EDFRow.EStart?
Should you perhaps be testing if it's Nothing
Didnt post all of my code, sorry
Dim EDFRow As ST102ADataSet.EDFRow
If Me.ENameListBox.SelectedItems.Count = 1 ThenEDFRow = ST102ADataSet.EDF.FindByEName(
Me.ENameListBox.SelectedValue.ToString)If IsDBNull(EDFRow.EStart) Then
Me.EStartDateTimePicker.Checked = FalseElseMe.EStartDateTimePicker.Checked = TrueEnd IfEDFRow.EStart is a field in a table that is a smalldate
IsNothing didnt work
IsNothing I thought would not work on a null field in a table, I thought IsNothing refers to a control only?
I am trying to find out if the fields value for the record is null, then if it is , get a date picker to not show a date until the field has data in it.
Davids Learning
I only suggested testing for Nothing in case you object had nothing to do with databases.
Anyhow, you still didn't answer my question.
It is an exeption error
It says that the field I am refering to is DBNull
It stops my code from executing to give me that error
Sorry
Davids Learning
This is the exact error
The value for column 'EStart' in table 'EDF' is DBNull.
<System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Public Property EStart() As DateGetTry Return CType(Me(Me.tableEDF.EStartColumn),Date)Catch e As System.InvalidCastExceptionThrow New System.Data.StrongTypingException("The value for column 'EStart' in table 'EDF' is DBNull.", e) <<This LineEnd TryEnd GetSetMe(Me.tableEDF.EStartColumn) = valueEnd SetEnd PropertyThere is nothing in the field in the database - it is a field that will hold a future date.
Davids Learning
Did you check the DataSet Designer that the Column is not set to ThrowException on DBNull?
Yes and it wont let me, this is the error
For columns not defined as System.String, the only valid value is (Throw exception).
This is a date field.
Is there a work around for this.
Davids Learning
If (EDFRow.isEStartNull = True) Then
Me.EStartDateTimePicker.Checked = False
Else
Me.EStartDateTimePicker.Checked = True
End If
isEStartNull Method is provided by default for typed datasets. :)
You are assuming that this line actually returns a value.
EDFRow = ST102ADataSet.EDF.FindByEName(Me.ENameListBox.SelectedValue.ToString)
Test EDFRow as follows:
If EDFRow IsNot Nothing Then
'do your other code here
Else
'do your else code here
End if