ADO.NET AddNew EndCurrentEdit & "Column 'Appt_ID' does not allow nulls"

T

tony010409020622

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

Thanks, Tony
 

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