troubleshooting Question

Getting DAL (strongly typed dataset) dbnull cast error for nullable field

Avatar of blackbr
blackbr asked on
ASP.NETVisual Basic.NETWeb Applications
7 Comments1 Solution1164 ViewsLast Modified:
I am using an xsd file against a sqlserver2005 db.  The field "street" is defined to allow nulls, as part of table Lender.

when I do a get data against the table adapter, and it encounters a null in that field, it executes the generated exception code below:
        <Global.System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
        Public Property STREET() As String
                    Return CType(Me(Me.tableLender.STREETColumn),String)
                Catch e As Global.System.InvalidCastException
                    Throw New Global.System.Data.StrongTypingException("The value for column 'STREET' in table 'Lender' is DBNull.", e)
                End Try
            End Get
                Me(Me.tableLender.STREETColumn) = value
            End Set
        End Property        <Global.System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Why is doing this, and how do I avoid it?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros