简体   繁体   中英

how can i allow null columns in vb.net?

does anyone know how can i allow null columns? i keep on getting this error:

NoNullAllowedException with database in visual basic

Column 'PRODUCT' does not allow nulls.

i have 3 forms. i do not get this error if i start to that certain form where it gets the value for the database, but if i start from my main form and do some form1.hide() and form2.show(), etc.., i get this error. any ideas? thanks.

btw i am using ms access as my database

If the database (MS Access in your case) doesn't allow NULL values to be inserted in a column, then you have to change the properties of the column (in MS Access) to allow NULL. You can't alter this behavior from VB. You either have to insert something or change your database to allow NULL. Whether or not this is a good idea we can't tell without looking at the database design.

It's not entirely clear from your question what actual .net code is executing, but I'm assuming this is happening when you're performing some data access, most likely having your datasource of a control bound directly to the table. If that's the case, see below.

You'll need to look up how to set the column itself as nullable in msaccess for that table. I imagine when the table was created the column is set to Not Null.

A related suggestion for allowing this in msAccess: MS Access - sql expression for allow null?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM