I have tried a large number of options to check for DBNull for a column returned in a dataset and I can't seem to figure it out. What I basically want is
Dim ds As ADMDS.PGListDataTableDim ta As New ADMDSTableAdapters.PGListTableAdapter
ds = ta.GetDataByPropertyGroupID(propertyGroup)
if (ds(i).prop_description is not null) then
... do something
How do I correctly check for DBNull Everything I try gives me the same error.
"The value for column 'prop_description' in table 'PGList' is DBNull."
Option 1:
l_tooltip = CType(ds(i).prop_description, SqlTypes.SqlString)
If (l_tooltip.IsNull = False) ThenOptions 2:
if (ds(i).prop_description.isnullorempty = true)
Option 3:
if (ifdbnull (ds(i).prop_description) = false) then
My whole procedure list below:
Public Sub CreateColumns(ByVal l_grid As AxEXGRIDLib.AxGrid, _
ByVal propertyGroup As Integer)
Try
Dim ds As ADMDS.PGListDataTable Dim ta As New ADMDSTableAdapters.PGListTableAdapter Dim ds1 As ADMDS.UserColumnOrderDataTable Dim ta1 As ADMDSTableAdapters.UserColumnOrderTableAdapter Dim i As Integer Dim l_tooltip As System.Data.SqlTypes.SqlStringds = ta.GetDataByPropertyGroupID(propertyGroup)
For i = 0 To ds.Count - 1 With l_grid.Columns.Add(ds(i).prop_name) 'If Not (ds(i).prop_description.ToString = String.Empty) Thenl_tooltip =
CType(ds(i).prop_description, SqlTypes.SqlString) If (l_tooltip.IsNull = False) Then.tooltip = l_tooltip.ToString
End If 'End If End With Next Catch ex As ExceptionShowMessage(
"", ex) End Try End Sub
How do you check for null values in a dataset column
AlexBB
Nope.. I get the same error: Am I using isdbnull correctly below
The value for column 'prop_description' in table 'PGList' is DBNull.
ds = ta.GetDataByPropertyGroupID(propertyGroup)
For i = 0 To ds.Count - 1 With l_grid.Columns.Add(ds(i).prop_name) If IsDBNull(ds(i).prop_description) Then Else 'l_tooltip = CType(ds(i).prop_description, SqlTypes.SqlString) 'If (l_tooltip.IsNull = False) Then.tooltip = ds(i).prop_description
'End If End If End With NextRattlerr
OK - Please clarify the line and the error that you are getting, whether you have option strict on or off.
And have you actually code stepped the code to determine if the correct value is being returned from the isdbnull method
dbnull is a class not a value.
Shril Pyrrho
gamer6000
oops, I am sorry I thought I replied to this last week.
I get the error on the line.
If ISDBnull(ds(i).prop_description) then
The error messages says : prop_description is DBNull.
Not sure that I understand the point about code stepped the isdbnull function.
Thanks
Brady
WilsonR
How about the isdbnull method to determine if it is or isnt set to dbnull.
Isdbnull Method
http://msdn2.microsoft.com/en-us/library/tckcces5.aspx
Marlon Smith
There appears to be a "feature" that prevents the DataSet Designer from changing the field to anything but ThrowException if the data type of the field is not string. The only solutions that I have found are to either bypass the strongly typed dataset property and reference the underlying column, or hack the generated code. Neither of these seem like a good long term solution. Are there any other alternatives that I am missing
Thanks
DevboyX
I only noticed this after you pointed it out. You might be better off posting a new post rather than replying to the orginal post that I posted.
Brady
stang4lyfe