Roland,
You are using a disconnected dataset and the columns have AllowDBNull set to false. You will need to populate each column with a default value before adding to the DataTable.
You can set the AutoIncrement property of a DataColumn in a DataTable
to True, and you can set the AutoIncrementSeed and AutoIncrementStep.
To avoid conflicts, one design pattern is to use -1 as both the seed
and the step, generating negative numbers in that column for new rows.
When you update, you can retrieve the real numbers.
Here's a help topic on AutoIncrement columns:
ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconcreatingautoincrementcolumns.htm
Here's a help topic on retrieving identity values:
ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconretrievingidentityorautonumbervalues.htm
And here's a useful KB article on handling parent/child updates with
identity keys:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q310350&GSSNB=1Here is a KB article about using a typed DataSet with default values
HOW TO: Make a Typed DataSet Return a Default Value Instead of DBNull by Using Visual Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q318039>Hi,
>
>I have been told not use Allow NULLs when defining an SQL Table. So I do not allow nulls in all fields.
>
>Everytime I turn around the app give me a message:
>
>System.Data.NoNullAllowedException: Column 'FileNum' does not allow nulls. This is an auto Increment field. All other fields will do the same thing if you do not enter a value.
>
>All SQL fields have a default value of '' Should I use something else like leaving the default blank (nothing) or ' ' one space or make it the number of spaces that is allowed in the field?
>
>What is the best way to handle allow null for fields using SQL Server 2000 and VB .net?
>
>Thanks
>Roland
-----------------------------------------
Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.comwww.prenia.comWeblog: blogs.prenia.com/cathi