Hello,
I am currently experimenting with databinding.
Now there is one problem I cannot seem to fix.
I have a DataSet with a DataTable. In this DataTable I have a Column which does not allow null values.
Now I have a BindingSource which has the DataSet as its DataSource and the DataTable as its DataMember and a BindingNavigator which has the BindingSource as its BindingSource property. All goes well until I leave the non-null column empty and try to navigate to another row in the DataTable or add a new row. It makes the application crash altogether... If I just call the DataSource.EndEdit method I only get a NoNullAllowedException.
The fields of my DataTable are shown in TextBoxes, not DataGrids.
I have checked all the DataSource events, properties, subs and functions, but I cannot find any method that allows me to check if all values are OK before I update/add new row/ navigate to another row or call the DataSource.EndEdit method.
Any suggestions on overcoming this? Thanks.
Amongst all the tags you applied to your question you forgot to include one for the type of Database (SQL Server, Access, MySQL, ????).
Still, one suggestion. If your database allows default values for columns setting that to 0 or any sensible number for your scenario might resolve the problem. If not, then having that TextBox initialized to a value of 0 (or whatever) might achieve the same result.
If neither of those suggestions suit, or as an alternative, consider handling the
Validating
[
^
] event.
Read the question carefully.
Understand that English isn't everyone's first language so be lenient of bad
spelling and grammar.
If a question is poorly phrased then either ask for clarification, ignore it, or
edit the question
and fix the problem. Insults are not welcome.
Don't tell someone to read the manual. Chances are they have and don't get it.
Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.