If a user chooses to clear a value in a DataBound TextBox by simply deleting the text and then save back to the database, an error is encountered because the column in the database does not allow Zero Length strings. I could just change the property of the database field to allow for the zero length strings, but I'd rather not.
I'm using a BindingSource as the DataSource and a CommandBuilder object so I can simply call the update method of the bindingsource. I could solve this problem by writing my update statements manually and checking for String.Empty, but I'd like to take advantage of the CommandBuilder's automatically created update method.
I've searched and found this code which is supposed to replace to String.Empty value with DBNull.Value.
I'm still received the error message. I've placed this line in the form load event, a method called "BindFields()" which simply clears and sets the DataBinding. Still, the errorr occurs.
Is this the correct way to accomplish this? Where should this line of code be placed?
I'm using a BindingSource as the DataSource and a CommandBuilder object so I can simply call the update method of the bindingsource. I could solve this problem by writing my update statements manually and checking for String.Empty, but I'd like to take advantage of the CommandBuilder's automatically created update method.
I've searched and found this code which is supposed to replace to String.Empty value with DBNull.Value.
vb.net Code:
Me.txtSalesOrder.DataBindings("Text").NullValue = String.Empty
I'm still received the error message. I've placed this line in the form load event, a method called "BindFields()" which simply clears and sets the DataBinding. Still, the errorr occurs.
Is this the correct way to accomplish this? Where should this line of code be placed?