Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 18th, 2008, 01:31 AM
Authorized User
 
Join Date: Jul 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default INSERT Fails

Im a student in south africa.I've set a primary key field to (int) data type but when im trying to insert a column it displays a message Like:"Cannot insert the value NULL into column 'VisitorId', table 'F:\LEX DIAMONDS\APP_DATA\DIARYDB.MDF.dbo.tblVisitor'; column does not allow nulls. INSERT fails."

supertedz
__________________
supertedz
 
Old July 18th, 2008, 02:50 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Is this a question or a statement? :)

If its a "this is my problem, can someone please help fix it" - then the error message is giving you all the information you need.

When adding a record, any required data must be set. You cannot have a null ID column, since, well, how do you ID something if its ID isn't set? It does not make sense!

Ensure you are setting the ID value for the record when inserting. You can do this a number of ways, use a GUID, increment based on the last used ID, create an ID based on the culmanation of various values etc..

What to use for an ID is always a hot topic of debate so I won't go there! :D

Rob
http://cantgrokwontgrok.blogspot.com
 
Old July 23rd, 2008, 08:56 AM
Authorized User
 
Join Date: Jul 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi there thanx 4 your words of a experienced programmer i got it right it was just a matter of setting a key. Ooh, Thanx man. :-)

Quote:
quote:Originally posted by robzyc
 Is this a question or a statement? :)

If its a "this is my problem, can someone please help fix it" - then the error message is giving you all the information you need.

When adding a record, any required data must be set. You cannot have a null ID column, since, well, how do you ID something if its ID isn't set? It does not make sense!

Ensure you are setting the ID value for the record when inserting. You can do this a number of ways, use a GUID, increment based on the last used ID, create an ID based on the culmanation of various values etc..

What to use for an ID is always a hot topic of debate so I won't go there! :D

Rob
http://cantgrokwontgrok.blogspot.com
supertedz
 
Old July 23rd, 2008, 08:58 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

No problem, happy to help :)
Always listen to the compiler, it can often be telling you exactly what you need to know ;)

Rob
http://cantgrokwontgrok.blogspot.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Job Fails - trying to insert into remote machine happygv SQL Server 2000 0 March 8th, 2007 10:03 AM
insert fails Mitch MySQL 3 June 3rd, 2006 11:48 AM
BULK INSERT FAILS everest SQL Server 2000 0 February 23rd, 2006 12:55 PM
Insert Record Fails W/ Unique Constraint snw C# 0 September 2nd, 2005 02:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.