does anyone know how can i allow null columns? i keep on getting this error:
有谁知道我怎么能允许空列?我继续收到此错误:
NoNullAllowedException with database in visual basic
在Visual Basic中使用数据库的NoNullAllowedException
Column 'PRODUCT' does not allow nulls.
列'PRODUCT'不允许空值。
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.
我有3种形式。如果我开始以某种形式获取数据库的值,我不会得到此错误,但如果我从我的主窗体开始并执行一些form1.hide()和form2.show()等等,我得到这个错误。有任何想法吗?谢谢。
btw i am using ms access as my database
顺便说一句,我使用ms访问作为我的数据库
2 个解决方案
#1
0
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.
如果数据库(在您的情况下为MS Access)不允许在列中插入NULL值,则必须更改列的属性(在MS Access中)以允许NULL。您无法从VB更改此行为。您必须插入内容或更改数据库以允许NULL。无论这是一个好主意,我们都不能不看数据库设计。
#2
0
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.
从您的问题中不完全清楚实际的.net代码正在执行什么,但我假设当您执行某些数据访问时会发生这种情况,很可能是您的控件的数据源直接绑定到表。如果是这种情况,请参阅下文。
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.
您需要查找如何在该表的msaccess中将列本身设置为可为空。我想在创建表时,列被设置为Not Null。
A related suggestion for allowing this in msAccess: MS Access - sql expression for allow null?
在msAccess中允许这个的相关建议:MS Access - sql表达式允许null?
#1
0
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.
如果数据库(在您的情况下为MS Access)不允许在列中插入NULL值,则必须更改列的属性(在MS Access中)以允许NULL。您无法从VB更改此行为。您必须插入内容或更改数据库以允许NULL。无论这是一个好主意,我们都不能不看数据库设计。
#2
0
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.
从您的问题中不完全清楚实际的.net代码正在执行什么,但我假设当您执行某些数据访问时会发生这种情况,很可能是您的控件的数据源直接绑定到表。如果是这种情况,请参阅下文。
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.
您需要查找如何在该表的msaccess中将列本身设置为可为空。我想在创建表时,列被设置为Not Null。
A related suggestion for allowing this in msAccess: MS Access - sql expression for allow null?
在msAccess中允许这个的相关建议:MS Access - sql表达式允许null?