Technote Details :: Column cannot be null
Issue
When submitting data into a database table, through a form, I get an error message,saying "General (or SQL) error: Column 'name' cannot be null".
For ASP_VBScript server model, the error is similar:
Error.SQL error: [Microsoft][ODBC Microsoft Access Driver] The field 'company_com.name_com' cannot contain a Null value because the Required property for this field is set to True. Enter a value in this field. 
- Operating System: All.
- Server Models: All.
- Dreamweaver version: MX, MX 2004.
Reason
This usually happens because a form field is left empty. One of the table columns used in the insert operation does not allow NULL values, which causes the insert to fail. The table column does not allow null values based on settings from the database software.
Solution
There are several solutions to this issue:
- If the column specified in the error message is not that important and could contain NULL values, alter the table structure and the column properties to allow NULL values. Instructions on how to do it should be provided with your database management software.
- Make sure to always enter a value in the corresponding form field or use Form Validation to check for a value before executing the SQL query.
- Set a default value for the form field, either through the wizard (Insert Record Wizard, Update Record Wizard or the NeXTensio Form Wizard) or by editing the corresponding server behavior.
See Also
| 1. |
Table does not exist
When using a form to add data into a table, instead of a successful SQL transaction, I get an [...]
|