Question Cathing NoNullAllowedException?

adshocker

Well-known member
Joined
Jun 30, 2007
Messages
180
Programming Experience
Beginner
hi all,

apparently, the exception is thrown when for example, i add a new row to the datatable then leave fields empty including columns which the AllowDBNull property set to False. i then try to add a new row or navigate to another row and that's when i get the error.

i've seen many forums giving work-around with this exception but i haven't any samples that really catches the exception.

the requirement is that

1. i need to some columns set AllowDBNull to False.
2. i need to prevent users from navigating away from a new record that has Not Nullable fields empty.
3. use bindingsource built-in events as much as possible.

can someone provide ways on how to go around this considering the requirements i have?

thanks.
 
Didn't we cover this topic elsewhere? I was under the impression that I'd told you how to write custom code for a BindingNavigator instead of letting handle the button clicks automatically.

There is no BindingSource event that is raised BEFORE navigating away from an item. If you want to validate your controls then that's exactly what you do. To validate a control you handle its Validating event. The user will then be unable to leave that control without entering valid data. To force ALL controls to be validated, including those that have not yet been visited, you can call ValidateChildren on the form.
 
Didn't we cover this topic elsewhere? I was under the impression that I'd told you how to write custom code for a BindingNavigator instead of letting handle the button clicks automatically.

just wanted to check if there are still other ways to do this. :D
 
just wanted to check if there are still other ways to do this. :D

I'm not sure what jmcilhinney's explanation was, and it's probably better than mine, but the way I do it is in a try catch

VB.NET:
try 
'what ever
catch duperror as System.Data.OleDb.OleDbException When ole.Errors(0).SQLState = 3022
' note the above is for duplicate entries


I did find this as a handy reference http://www.fairport.com.au/FAQ/know2.asp?fid=66
and i think the one that you're looking for is # 3314

but all of this is if I'm not mistaken, which most of the time I am...
 
Back
Top