This documentation is archived and is not being maintained.

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.

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.

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.

Show: