473,322 Members | 1,259 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,322 software developers and data experts.

Column does not allow nulls when saving

Hi

I have a vb.net winform data app with sql server 2005 backend. The ID field
in the tblClients table is an 'int' identity column that does not allow
nulls. The problem is that when I try to save the record using the below
code;

Me.Validate()
Me.CompaniesBindingSource.EndEdit()
Me.CompanyTableAdapter.Update(Me.EMSDataSet.tblCli ents)

I get an 'Column 'ID' does not allow nulls' error on the second line
(EndEdit()). The first few lines of stack trace is below. What is the
problem and how can I fix it?

Thanks

Regards

----------------

Stack Trace

System.Data.NoNullAllowedException was unhandled
Message="Column 'ID' does not allow nulls."
Source="System.Data"
StackTrace:
at System.Data.DataColumn.CheckNullable(DataRow row)
at System.Data.DataTable.RaiseRowChanging(DataRowChan geEventArgs
args, DataRow eRow, DataRowAction eAction, Boolean fireEvent)
Mar 3 '07 #1
5 12572
On Mar 3, 10:05 am, "John" <J...@nospam.infovis.co.ukwrote:
Hi

I have a vb.net winform data app with sql server 2005 backend. The ID field
in the tblClients table is an 'int' identity column that does not allow
nulls. The problem is that when I try to save the record using the below
code;

Me.Validate()
Me.CompaniesBindingSource.EndEdit()
Me.CompanyTableAdapter.Update(Me.EMSDataSet.tblCli ents)

I get an 'Column 'ID' does not allow nulls' error on the second line
(EndEdit()). The first few lines of stack trace is below. What is the
problem and how can I fix it?

Thanks

Regards

----------------

Stack Trace

System.Data.NoNullAllowedException was unhandled
Message="Column 'ID' does not allow nulls."
Source="System.Data"
StackTrace:
at System.Data.DataColumn.CheckNullable(DataRow row)
at System.Data.DataTable.RaiseRowChanging(DataRowChan geEventArgs
args, DataRow eRow, DataRowAction eAction, Boolean fireEvent)
Is your code trying to insert NULL into the identity column?

Mar 3 '07 #2
I designed the app visually by dragging tables and controls over dataset and
forms. I would have thought the auto generated code would have taken care of
it. Where can I check? Sorry for being dumb. While configuring data adapter
I did choose stored procedures instead of sql.

Thanks

Regards

"Steve" <mo********@hotmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
On Mar 3, 10:05 am, "John" <J...@nospam.infovis.co.ukwrote:
>Hi

I have a vb.net winform data app with sql server 2005 backend. The ID
field
in the tblClients table is an 'int' identity column that does not allow
nulls. The problem is that when I try to save the record using the below
code;

Me.Validate()
Me.CompaniesBindingSource.EndEdit()
Me.CompanyTableAdapter.Update(Me.EMSDataSet.tblCl ients)

I get an 'Column 'ID' does not allow nulls' error on the second line
(EndEdit()). The first few lines of stack trace is below. What is the
problem and how can I fix it?

Thanks

Regards

----------------

Stack Trace

System.Data.NoNullAllowedException was unhandled
Message="Column 'ID' does not allow nulls."
Source="System.Data"
StackTrace:
at System.Data.DataColumn.CheckNullable(DataRow row)
at System.Data.DataTable.RaiseRowChanging(DataRowChan geEventArgs
args, DataRow eRow, DataRowAction eAction, Boolean fireEvent)

Is your code trying to insert NULL into the identity column?

Mar 3 '07 #3
John (Jo**@nospam.infovis.co.uk) writes:
I designed the app visually by dragging tables and controls over dataset
and forms. I would have thought the auto generated code would have taken
care of it. Where can I check? Sorry for being dumb. While configuring
data adapter I did choose stored procedures instead of sql.
You are dragging and dropping instead of writing real code, and then you
ask why it doesn't work? :-)

Since I'm coming from the SQL Server side of things, my suggestion would
be to use the Profiler to see what is actually being sent to SQL Server.
Since you selected to use stored procedures, you should be able to find
those procedures somewhere. I don't exactly what that dragging and
dropping performs, but it should result in code that is available in
your project.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Mar 3 '07 #4
First, remove the UPDATE and see if it's really EndEdit causing the
problems, or if it's the Update command.

If it's EndEdit, look at your dataset in the dataset designer and click on
the primary key (autonumber) field. Make sure it's set to autoincrement,
and the seed fields are -1 (autoincrementseed and autoincrementstep).

Robin S.
-----------------------------
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:Oo**************@TK2MSFTNGP02.phx.gbl...
>I designed the app visually by dragging tables and controls over dataset
and forms. I would have thought the auto generated code would have taken
care of it. Where can I check? Sorry for being dumb. While configuring
data adapter I did choose stored procedures instead of sql.

Thanks

Regards

"Steve" <mo********@hotmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
>On Mar 3, 10:05 am, "John" <J...@nospam.infovis.co.ukwrote:
>>Hi

I have a vb.net winform data app with sql server 2005 backend. The ID
field
in the tblClients table is an 'int' identity column that does not allow
nulls. The problem is that when I try to save the record using the
below
code;

Me.Validate()
Me.CompaniesBindingSource.EndEdit()
Me.CompanyTableAdapter.Update(Me.EMSDataSet.tblC lients)

I get an 'Column 'ID' does not allow nulls' error on the second line
(EndEdit()). The first few lines of stack trace is below. What is the
problem and how can I fix it?

Thanks

Regards

----------------

Stack Trace

System.Data.NoNullAllowedException was unhandled
Message="Column 'ID' does not allow nulls."
Source="System.Data"
StackTrace:
at System.Data.DataColumn.CheckNullable(DataRow row)
at System.Data.DataTable.RaiseRowChanging(DataRowChan geEventArgs
args, DataRow eRow, DataRowAction eAction, Boolean fireEvent)

Is your code trying to insert NULL into the identity column?


Mar 4 '07 #5
John,

The change that it is in the identy column is very small, it does not matter
at all what is in that column at an insert. So have a look at the other
columns.

Cor

"John" <Jo**@nospam.infovis.co.ukschreef in bericht
news:Oo**************@TK2MSFTNGP02.phx.gbl...
>I designed the app visually by dragging tables and controls over dataset
and forms. I would have thought the auto generated code would have taken
care of it. Where can I check? Sorry for being dumb. While configuring data
adapter I did choose stored procedures instead of sql.

Thanks

Regards

"Steve" <mo********@hotmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
>On Mar 3, 10:05 am, "John" <J...@nospam.infovis.co.ukwrote:
>>Hi

I have a vb.net winform data app with sql server 2005 backend. The ID
field
in the tblClients table is an 'int' identity column that does not allow
nulls. The problem is that when I try to save the record using the below
code;

Me.Validate()
Me.CompaniesBindingSource.EndEdit()
Me.CompanyTableAdapter.Update(Me.EMSDataSet.tblC lients)

I get an 'Column 'ID' does not allow nulls' error on the second line
(EndEdit()). The first few lines of stack trace is below. What is the
problem and how can I fix it?

Thanks

Regards

----------------

Stack Trace

System.Data.NoNullAllowedException was unhandled
Message="Column 'ID' does not allow nulls."
Source="System.Data"
StackTrace:
at System.Data.DataColumn.CheckNullable(DataRow row)
at System.Data.DataTable.RaiseRowChanging(DataRowChan geEventArgs
args, DataRow eRow, DataRowAction eAction, Boolean fireEvent)

Is your code trying to insert NULL into the identity column?


Mar 4 '07 #6

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

Similar topics

1
by: Joao Santa Barbara | last post by:
Hi all i have a grid bind with a dataset, and a textbox. i´m using a currency manager to navigate in the grid, but some times when i press the CM.Addnew it shows a message in the screen " Column...
3
by: Prince Kumar | last post by:
Is there any way I can define an Unique constraint or unique index which allows more than one null values for the same column combination in DB2? ie, If my index is defined on (col3, col4) where...
5
by: Robert Stearns | last post by:
Either I missed something, or ALTER TABLE does not have this capability. Is there any way of doing it except DROPping all constraints which mention this table, EXPORTing the data, DROPping the...
0
by: Steve Amey | last post by:
Hi all I am having a problem when I am updating my database. I am using a strong DS and the PK column is an Identity column, but when I am udating my database I am getting the exception 'Column...
1
by: Martin Widmer | last post by:
Hi guys! I get this message when trying to insert a new record into a datatabel which is part of a dataset connected within VS 2005 (VB) from a datagridview control via a DataTableBindingSource...
5
by: deekay | last post by:
I want to allow users to resize and reposition columns of a datasheet but for a prompt to be brought up and only the layout only to be saved if they select "save changes". This is the way it works...
1
by: mrkselm | last post by:
Hi, I am stuck with a problem in MS Access which does not occur in SQL Server and I have been banging my head against the wall for a couple of days now trying to resolve it. Namely, when I...
1
by: tashy | last post by:
I initially modified the column 'ID' from not allowing NULL to allow, and saved it. But now I will like to change it back to 'not allow'. But it gives me the following error message: 'Pages' table...
0
by: csauer | last post by:
I am writing a program using visual basic.NET 2003 to be used to update and store data in a database I have stored in Access 2003. I am using a OdbcDataAdapter to generate my dataset, then using a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.