Поле Int в winform не обновляет нулевые значения в базе данных SQL server с помощью C#
In my Winforms C# application, I have fields with Int data type and they are set to accept null values in SQL Server database (allow nulls). In the forms I have some textboxes which are bound to those int data type fields. If I don't enter anything while creating a new record, it accepts and saves record in sql database. If I enter a number in the textbox, it also accepts it, and then if I delete the number, it doesn't allow me to move to the next field. If I set its value as null or "" through code, it is not updated in database and even does not update changes which I made in other non int text fields (this update works fine if I dont touch int fields). I am using following to enter null in this field.
IDTextBox.Text = ""; IDTextBox.Text = null;
On Form Load event, I have following code.
this.itemsTableAdapter.Fill(this.sBSDBDataSet.Items);
I am using following code to save new record in database
this.itemsbindingSource.AddNew(); this.Validate(); this.itemsbindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.sBSDBDataSet);
On this form there are many fields in which I enter data and then press UPDATE button to update the record in SQL Server database. I am using following method to update the record
this.Validate(); this.itemsbindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.sBSDBDataSet);
All other fields seem to work fine except the fields having int datatype (although in sql table I have allowed them to be null). . As I mentioned above, int field text box on WinForm does not even allow to move to next field during data entry if we do not enter something in it What can I do for the textbox accept null values?
Что я уже пробовал:
Я много гуглил, но не нашел никакого решения своей проблемы.