I am using ASP.NET 2.0 codebehind Visual Basic, Visual Studio 2005
Working with DataSet creating a Data Access Layer via VS 2005.
My error is when the code that is prewritten by VS 2005 Casts to String but
the data inside the column is a NULL.
Code prewritten by visual studio:
<System.Diagnos tics.DebuggerNo nUserCodeAttrib ute()_
Public Property SuiteFloor() As String
Get
Try
Return CType(Me(Me.tab leaspnet_getMyI nfo.SuiteFloorC olumn),String)
Catch e As System.InvalidC astException
Throw New System.Data.Str ongTypingExcept ion("The value for column
'SuiteFloor' in table 'aspnet_getMyIn fo' is DBNull.", e)
End Try
End Get
Set
Me(Me.tableaspn et_getMyInfo.Su iteFloorColumn) = value
End Set
End Property
It throws an error becuase the value in the database is NULL.
{"The value for column 'SuiteFloor' in table 'aspnet_getMyIn fo' is DBNull."}
I tried to perform this code in my .aspx page:
Public Sub populateMyInfoD ata(ByVal orgID As String)
Dim MyInfoDataAdapt er As New
dsMyInfoTableAd apters.aspnet_g etMyInfoDataTab leAdapter
Dim MyInfoData As dsMyInfo.aspnet _getMyInfoDataD ataTable
Dim cc As dsMyInfo.aspnet _getCrownCorpDa taRow
MyInfoData = crownDataAdapte r.GetData_Byorg IDLanguageID(la nguageID, orgID)
For Each cc In MyInfoData
'Response.Write ("Suite/Floor: " & cc.SuiteFloor & "<br>")
'Response.Write ("Street Address: " & cc.StreetAddres s & "<br>")
'On all fields below,
'Check that the field does not contain a NULL value
'SuiteFloor
If IsDBNull(cc.Sui teFloor) Then
txtSuiteFloor.T ext = ""
Else
txtSuiteFloor.T ext = cc.SuiteFloor
End If
This had no affect because the error is THROWN when inside the Property
method.
Does anyone have any ideas how to resolve this issue?
Thanks in advance,
~Brad
------------------------------
Brad Isaacs
bi*****@rogers. com