IsDBNull ~ Precompiled code in .NET~Help Please

B

Brad Isaacs

ASp.NET 2.0 , Visual Studio 2005

I am working with the Add NEw Item >> DataSet
I have created my Dataset and call it, when I run my project, I receive an
error message because the dataset is pulling a DBNULL value.

I was suggestted to add the following IF ELSE and it makes sense to do that
:
<System.Diagnostics.DebuggerNonUserCodeAttribute()> _

Public Property SuiteFloor() As String

Get

Try

If isDbNull(Me.tableaspnet_getCrownCorpData.SuiteFloorColumn) Then

Return ""

Else

Return CType(Me(Me.tableaspnet_getCrownCorpData.SuiteFloorColumn), String)

End If

Catch e As System.InvalidCastException

Throw New System.Data.StrongTypingException("The value for column
'SuiteFloor' in table 'aspnet_getCrownCorpData' is DBNull.", e)

End Try

End Get

Set

Me(Me.tableaspnet_getCrownCorpData.SuiteFloorColumn) = value

End Set

End Property

The above code looks great,

However, after saving this file >>> App_Code.91dxmfxl.1.vb and ReBuilding my
Web site, I ran into the same issue.........because it seems that the
Project runs a different file named >> App_Code.wyx3j.1.vb with the original
precompiled code and does not see my changes to the code:

<System.Diagnostics.DebuggerNonUserCodeAttribute()> _

Public Property SuiteFloor() As String

Get

Try

Return CType(Me(Me.tableaspnet_getCrownCorpData.SuiteFloorColumn),String)

Catch e As System.InvalidCastException

Throw New System.Data.StrongTypingException("The value for column
'SuiteFloor' in table 'aspnet_getCrownCorpData' is DBNull.", e)

End Try

End Get

Set

Me(Me.tableaspnet_getCrownCorpData.SuiteFloorColumn) = value

End Set

End Property





Is there any way around this............any ideas/ suggesttions would be
greatly appreciated.

Thanks,

~Brad
ps: It just seems stupid that you cannot adjust this code.............
 
G

Guest

Hi Brad,

1. First, there's a statement at the top of generated designer dataset file,
saying that you should not change the content of the file, because changes
will be lost next time file is refreshed.
2. Second, your code won’t work because you’re checking if reference to
SuiteFloorColumn column is DBULL which is never true; it should evaluate row
value from column /or column name/column index:

Return CType(Me(Me.tableaspnet_getCrownCorpData.SuiteFloorColumn),String)

This is what actually is rendered by Visual studio automatically.
3. Third, designer generates a special property for this type of check
IsColumnNameNUull for these types of checking. In you case it will be :

If myTypeDataDataSet.TableName.Rows[0].IsSuiteFloorColumnNull() then
End if

Hope it’s clear now

Have a nice day
 
B

Brad Isaacs

Hi Milosz,

Thank you very much for your help.

~Brad


Milosz Skalecki said:
Hi Brad,

1. First, there's a statement at the top of generated designer dataset
file,
saying that you should not change the content of the file, because changes
will be lost next time file is refreshed.
2. Second, your code won't work because you're checking if reference to
SuiteFloorColumn column is DBULL which is never true; it should evaluate
row
value from column /or column name/column index:

Return CType(Me(Me.tableaspnet_getCrownCorpData.SuiteFloorColumn),String)

This is what actually is rendered by Visual studio automatically.
3. Third, designer generates a special property for this type of check
IsColumnNameNUull for these types of checking. In you case it will be :

If myTypeDataDataSet.TableName.Rows[0].IsSuiteFloorColumnNull() then
End if

Hope it's clear now

Have a nice day
--
Milosz

Brad Isaacs said:
ASp.NET 2.0 , Visual Studio 2005

I am working with the Add NEw Item >> DataSet
I have created my Dataset and call it, when I run my project, I receive
an
error message because the dataset is pulling a DBNULL value.

I was suggestted to add the following IF ELSE and it makes sense to do
that
:
<System.Diagnostics.DebuggerNonUserCodeAttribute()> _

Public Property SuiteFloor() As String

Get

Try

If isDbNull(Me.tableaspnet_getCrownCorpData.SuiteFloorColumn) Then

Return ""

Else

Return CType(Me(Me.tableaspnet_getCrownCorpData.SuiteFloorColumn),
String)

End If

Catch e As System.InvalidCastException

Throw New System.Data.StrongTypingException("The value for column
'SuiteFloor' in table 'aspnet_getCrownCorpData' is DBNull.", e)

End Try

End Get

Set

Me(Me.tableaspnet_getCrownCorpData.SuiteFloorColumn) = value

End Set

End Property

The above code looks great,

However, after saving this file >>> App_Code.91dxmfxl.1.vb and ReBuilding
my
Web site, I ran into the same issue.........because it seems that the
Project runs a different file named >> App_Code.wyx3j.1.vb with the
original
precompiled code and does not see my changes to the code:

<System.Diagnostics.DebuggerNonUserCodeAttribute()> _

Public Property SuiteFloor() As String

Get

Try

Return CType(Me(Me.tableaspnet_getCrownCorpData.SuiteFloorColumn),String)

Catch e As System.InvalidCastException

Throw New System.Data.StrongTypingException("The value for column
'SuiteFloor' in table 'aspnet_getCrownCorpData' is DBNull.", e)

End Try

End Get

Set

Me(Me.tableaspnet_getCrownCorpData.SuiteFloorColumn) = value

End Set

End Property





Is there any way around this............any ideas/ suggesttions would be
greatly appreciated.

Thanks,

~Brad
ps: It just seems stupid that you cannot adjust this code.............
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top