Groups | Blog | Home
all groups > dotnet ado.net > september 2005 >

dotnet ado.net : ADO.NET AddNew EndCurrentEdit & "Column 'Appt_ID' does not allow nulls"


tony010409020622 NO[at]SPAM spamthis NO[at]SPAM hotmail.com
9/28/2005 12:00:00 AM

Having spent a lot of time Googling over the last 2 days, this seems
like a common problem, but I havent run into any answers:

My VB.Net front end loads data from an Access database successfully,
and navigation works fine. However, I cannot add a record. Code is as
follows:

In my Add New Record button:

REM move to last record
Call btnLast_Click(Nothing, Nothing)
REM clear text boxes, prepare for new record
Me.BindingContext(DsAppointments1, "Appointments").AddNew()

In my Update button:

REM commit to adding new record
Me.BindingContext(DsAppointments1, "Appointments").EndCurrentEdit()

When that last line of code fires, I get the following error (I know
this must be starting to look familiar to experienced coders):

--------------
"An unhandled exception of type 'System.Data.NoNullAllowedException'
occurred in system.data.dll

Additional information: Column 'Appt_ID' does not allow nulls."
--------------

Appt_ID is the primary key and is set to autonumber in the Access
database. I have tried too many things to even mention here, but I
cannot get this to work. I'm sure someone out there has gotten it to
work, and I'd love to know how. :-)

Also, a curiosity. What is the VB.Net equivelent of:
Adodc1.Recordset.Fields(0).Value

Cor Ligthert [MVP]
9/28/2005 9:27:38 AM
Tony,

I am not sure anymore, I thought that this one resolved your problem.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatamissingschemaactionclasstopic.asp

Although adding these is as well not bad (see the sample to get it complete)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclassautoincrementsteptopic.asp

I hope this helps,

Cor

<tony010409020622@spamthis@hotmail.com> schreef in bericht
news:uftjj1t1kkmd0n7utknvjein8ucc6i6os0@4ax.com...
[quoted text, click to view]

tony010409020622 NO[at]SPAM spamthis NO[at]SPAM hotmail.com
9/28/2005 9:40:43 PM

On Wed, 28 Sep 2005 09:27:38 +0200, "Cor Ligthert [MVP]"
[quoted text, click to view]


You must be thinking of someone else, I haven't posted in this
AddThis Social Bookmark Button