473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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(DataRowChan geEventArgs args, DataRow
eRow, DataRowAction eAction, Boolean fireEvent)
.....
.....
.....
System.Windows.Forms.DataGridView.DatGridViewDataC onnection.OnRowValidating(DataGridViewCell CancelEventArgs e
--
L. A. Jones
Apr 27 '06 #1
1 6908
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.

Dave wrote:
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(DataRowChan geEventArgs args, DataRow
eRow, DataRowAction eAction, Boolean fireEvent)
....
....
....
System.Windows.Forms.DataGridView.DatGridViewDataC onnection.OnRowValidating(DataGridViewCell CancelEventArgs e

Apr 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Howard | last post by:
I have a datagrid view and a commit button My default datagrid view shows me the results from the database but update or insert doesn't work how can i make it so that it will update the data in...
0
by: TNSFED | last post by:
I have a dilemma when trying to delete a row from the DataGridView. Here is a sample of my code: private void dgv_EQUPS_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) {...
0
by: Dave | last post by:
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...
0
by: Bob Roggy | last post by:
I would like to write transaction activity to a journal table, specifying Add, Update, or Delete and some information regarding each transaction when a user works in a datagridview. I have...
4
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
2
by: Martin | last post by:
Hi all, This is the situation... DatagridView Control with datasource set to datatable. I want the user to be able to delete x number of rows by selecting a row with mouse then clicking a...
1
by: abhi81 | last post by:
Hello All, I have a table on which I have created a insert,Update and a Delete trigger. All these triggers write a entry to another audit table with the unique key for each table and the timestamp....
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
4
by: =?Utf-8?B?dGVfYnV0dHM=?= | last post by:
Using VS2005, and SQL 2005 Express. Here is the situation: SQL - 1 Table called Products - First Column called ProductsID (Uniqueidentifier)(newid()) - So it adds new UI when new row is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.