Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 May 3rd, 2011, 11:34 PM
Registered User
 
Join Date: May 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 14 - Second Try it Out section

Hi Everyone

I am working on the second try it now section in chapter 14 where I encounter an error at step 16 - (Save all your changes, close all open files, and then request NewPhotoAlbum.aspx). When I insert a name and click 'Insert' I get a ASP.NET yellow page of death that states "Object reference not set to an instance of an object"

When I place a break point (*) at:
Code:
protected void EntityDataSource1_Inserted(object sender, EntityDataSourceChangedEventArgs e)
  {
   (*) PhotoAlbum myPhotoAlbum = (PhotoAlbum)e.Entity;
At this point e is null and when I drill down to find more information I find the following exception:

InnerException = {"Cannot insert explicit value for identity column in table 'PhotoAlbum' when IDENTITY_INSERT is set to OFF."}

How can I set this property from VS 2010? Has anyone else received this error?

I would greatly appreciate anyone's help.

Thanks,
 
Old May 4th, 2011, 03:35 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take a look at Step 1 of the exercise at page 498. It shows you the table definition and explains how to make the Id column an identity.

After you changed the database, you need to update the EF model. You can right-click the design surface and choose Update model from database and follow the wizard. Alternatively, you can delete the tables from the EF diagram and add them again.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
olias (May 4th, 2011)
 
Old May 4th, 2011, 12:38 PM
Registered User
 
Join Date: May 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Smile Thanks Imar

Thanks Imar

That did it!!

This is a great book, I am really enjoying it!!
 
Old May 4th, 2011, 12:42 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
This is a great book, I am really enjoying it!!
Thank you! Have fun with the remaining chapters.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sugestion for Chapter 10 LINQ section mangel BOOK: Professional Visual Basic 2010 and .NET 4 0 April 4th, 2011 04:41 PM
Chapter 14, first 'Try It Out' alharlow BOOK: Beginning ASP.NET 4 : in C# and VB 5 March 18th, 2011 05:00 AM
chapter 14 vthunder70 BOOK: Beginning ASP.NET 2.0 and Databases 2 October 3rd, 2007 02:11 PM
Chapter 14 JonG BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 March 21st, 2006 10:04 PM
Chapter 14 Mike Smith BOOK: Professional C#, 2nd and 3rd Editions 2 January 4th, 2004 05:13 PM





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