Compartilhar via


Troubleshooting Exceptions: System.Data.NoNullAllowedException 

A NoNullAllowedException exception is thrown when there is an attempt to insert a null value into a column where AllowDBNull is set to false.

Associated Tips

  • Check to determine if the value is DBNull before adding it to the column.
    If AllowDBNull is set to false, you will not be able to insert a null value. For more information, see DBNull.
  • Set AllowDBNull to true.
    Setting this property to true will allow you to inset null values. For more information, see AllowDBNull.

Remarks

If you use the navigation buttons to move through the records of a database table on a data form, this exception may be thrown with the additional information, "Column 'Column' does not allow nulls." This behavior occurs because the primary key or the "not NULL" column of the database table was not selected in the Data Form Wizard. If the primary key or the "not NULL" column of the database is not selected in the Data Form Wizard when you create the data form, the Add- Creates a new record option is not disabled. To work around this problem, select the following columns of the selected table when you add a data form by using the Data Form Wizard: the primary column and a column that does not permit NULLs.

See Also

Tasks

How to: Find Out More About an Exception with the Exception Assistant
How to: Create a New DataRow Based on an Existing DataTable (Visual Basic)

Reference

NoNullAllowedException
Add
EndEdit
ItemArray
LoadDataRow