DataGridView will update & delete but will not insert. (Using auto

G

Guest

I have a table with 3 fields of which the primary key is a autonumber. I have
created my dataadapter, dataset and datagridview using a wizard. However, in
the datagrid, the update and delete operation work but the Insert will not
work. I know I to make changes to code but it does not seem to work. portion
of the error reads:

The following exception occurred in the DataGridView:
System.Data.NoNullAllowedException: Column 'ID' does not allow nulls at
System.Data.DataColumn.CheckNullable(DataRow row) at
System.Data.DataTable.RaiseRowChanging(DataRowChangeEventArgs args, DataRow
eRow, DataRowAction eAction, Boolean fireEvent)
.....
.....
.....
System.Windows.Forms.DataGridView.DatGridViewDataConnection.OnRowValidating(DataGridViewCell CancelEventArgs e
 
I

Ian Semmel

I reckon DataGridView is broken.

To do a simple thing like tab thru a bound table adding records takes all sorts
of tricks for boundary conditions like the first record in an empty dataset. It
shouldn't be so hard.

When you tab into a new row, and start typing, UserAddedRow gets called with a
row number 2 greater than the actual row you are typing in.

Tracing the calls that DGV makes, it appears that whoever wrote the code
programmed themselves into a corner. Instead of a logical progression of
function calls, it appears that to ensure that the correct function gets called,
they decided to call everything.

If you examine DGV.Rows.Count, sometimes it equals the current row, sometimes
the next, and sometimes the one after that.

I can successfully add one row at the end, but the next row I add disappears
because, I think, the dataset tablerow status is not set correctly.
 

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