Home All Groups Group Topic Archive Search About

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

Author
17 Jan 2006 2:17 PM
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

Author
17 Jan 2006 2:24 PM
Chris
Martin Widmer wrote:
Show quoteHide quote
> 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