System.Data.NoNullAllowedException: Column 'frDateCreated' does not allow nulls

M

Martin Widmer

Hi guys!

I get this message when trying to insert a new record into a datatabel which
is part of a dataset connected within VS 2005 (VB) from a datagridview
control via a DataTableBindingSource and TableAdapter to an SQL Server. In
the SQL server the field is declared as "do now allow null", BUT I put the
getdate() function as default value so the field should be automatically
filled with the current date.

So why do I get that exception up there? Does SQL server test for NULL
actually BEFORE inserting the default value? That would be rather stupid,
wouldn't it?

When I insert the record manually via the server explorer, the error does
not occur.

Martin
 
C

Chris

Martin said:
Hi guys!

I get this message when trying to insert a new record into a datatabel which
is part of a dataset connected within VS 2005 (VB) from a datagridview
control via a DataTableBindingSource and TableAdapter to an SQL Server. In
the SQL server the field is declared as "do now allow null", BUT I put the
getdate() function as default value so the field should be automatically
filled with the current date.

So why do I get that exception up there? Does SQL server test for NULL
actually BEFORE inserting the default value? That would be rather stupid,
wouldn't it?

When I insert the record manually via the server explorer, the error does
not occur.

Martin

When do you get the exception, when trying to insert into your local
dataset or when trying to insert into the SQL server? My quess is your
local dataset, which AFAIK, does not know your default values. Try
setting the default value of the column you want on the datatable. That
should clear up your issue.

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top