I am probably doing this wrong
If
IsDBNull(EDFRow.EStart) Then Me.EStartDateTimePicker.Checked = False Else Me.EStartDateTimePicker.Checked = True End If I get the error that the filed is dbnullCan someone please explain this.
Davids Learning
I am probably doing this wrong
If
IsDBNull(EDFRow.EStart) Then Me.EStartDateTimePicker.Checked = False Else Me.EStartDateTimePicker.Checked = True End If I get the error that the filed is dbnullCan someone please explain this.
Davids Learning
IsDBNull problem
T-W
I only suggested testing for Nothing in case you object had nothing to do with databases.
Anyhow, you still didn't answer my question.
bennett_chen
Isdbnull Method
http://msdn2.microsoft.com/en-us/library/tckcces5.aspx
Returns a Boolean value indicating whether an expression evaluates to the System.DBNull class.
DBNull Class
Represents a nonexistent value. This class cannot be inherited
DBnull is in fact system.dbnull and is a class, Null (Nothing) in vb is not the same as dbnull. So you need to be careful that you are using the right one otherwise it may provide strange results.
A search on the forums on isdbnull will detail it and potential pitfalls that can cause confusing results. I'd suggest having a look at these and see if either of these actually helps you out.
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=555922&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=129341&SiteID=1
Which line specifically is throwing the exception
and what value do you think should be in the database for this item
Modez
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
madrikh
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
bchu
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
Steve Hempen
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
TomJ72
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 = False Else Me.EStartDateTimePicker.Checked = True End 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
laboremus
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. :)
Krela
This is the exact error
The value for column 'EStart' in table 'EDF' is DBNull.
<System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Public Property EStart() As Date Get Try Return CType(Me(Me.tableEDF.EStartColumn),Date) Catch e As System.InvalidCastException Throw New System.Data.StrongTypingException("The value for column 'EStart' in table 'EDF' is DBNull.", e) <<This Line End Try End Get Set Me(Me.tableEDF.EStartColumn) = value End Set End PropertyThere is nothing in the field in the database - it is a field that will hold a future date.
Davids Learning
auto
Did you check the DataSet Designer that the Column is not set to ThrowException on DBNull