I have a field in my database table which is an integer and allows null values. There is no default value.
In my object model, that field shows properties of type = Int32 and Nullable = True.
I use this code for updating the DB:
Dim objBlend As New Blend
objBlend = (From c In DbContext.Blends Where c.BlendID = txtBlendID_E.Text Select c).FirstOrDefault
objBlend.SyteLineID = txtSyteline_E.Text
So the user types a number in the textbox ("txtSyteline_E") and clicks the save button which invokes the code above. When the textbox has a value, it works fine. However, if the user leaves the textbox blank, because he is trying to erase the existing database value, it throws an error "Input string is not in a correct format".
So what's the correct format for saving nulls back to the DB?
Like most programmers, I am desperate to solve this. Any and all help is greatly appreciated.