I'm loving MVC but unfortunately all the tutorials, demos and ALL resources use Entity Framework to generate ViewData and most use LINQ to SQL instead of DataSets.
I'm reusing existing business logic and the client (who is a great coder in his own right) wants to keep using Datasets... so i cant move away from these.
I have one table that contains columns which are allowed to be NULL in the database. When i try to access these...even to check if it's null i get an exception:
"The value for column 'FNN_CARRIERS_DESC' in table 'FNN_CARRIERS_DESC' is DBNull"
Now this is generated by the dataset.designer.vb file.
I know what you're going to say. "FNN_BRAND IS Null!!!" and that is true. But...follow the stack trace and the line in my code that is generating this error is this:
<%= Html.TextBox("FNN_CARRIERS_DESCTextBox", If(IsNothing(Model.FNN_CARRIERS_DESC), Model.FNN_CARRIERS_DESC, ""))%>
Guidance would be greatly appreciated! My inutition tells me this is not strictly an MVC problem but maybe something i don't understand about datasets.
This is the code in the reference.vb file that throws the exception:
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")> _
Public Property FNN_CARRIERS_DESC() As String
Get
Try
Return CType(Me(Me.tableVIT_FNN_CommsService.FNN_CARRIERS_DESCColumn),String)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'FNN_CARRIERS_DESC' in table 'VIT_FNN_CommsService' is DBNul"& _
"l.", e)
End Try
End Get
Set
Me(Me.tableVIT_FNN_CommsService.FNN_CARRIERS_DESCColumn) = value
End Set
End Property
Things i've tried:
I need to know the best way to solve this, hopefully keeping in with the MVC architecture.
Help me fellow nerds... you're my only hope!
If anyone is interested i found a better solution... one that lets you keep using datasets without a layer in the middle.
A column is nullable the dataset actually provides a method for you.
Model.isFNN_CARRIERS_DESCNull()
so one could check the nullability of this column...without causing a crash.