Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 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 June 29th, 2007, 12:58 PM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default OnLine Diary conversion to C#

I am trying to convert the Online Diary project to C#. Almost everything works. The problem I am having is when trying to save a contact, diary entry, diary event that call the SAVE() function. On all of these I get an error for "sqlCmd.ExecuteNonQuery();" I think its something to do with some of the variables I defined that dont match the correct type they need to be. Here is the typical error I get.


The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Event_Diary". The conflict occurred in database "D:\USERS\TRENT\DOCUMENTS\VISUAL STUDIO 2005\WEBSITES\ONLINEC\APP_DATA\DIARYDB.MDF", table "dbo.Diary", column 'DiaryId'.
The statement has been terminated.
The 'InsertDiaryEvent' procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Event_Diary". The conflict occurred in database "D:\USERS\TRENT\DOCUMENTS\VISUAL STUDIO 2005\WEBSITES\ONLINEC\APP_DATA\DIARYDB.MDF", table "dbo.Diary", column 'DiaryId'.
The statement has been terminated.
The 'InsertDiaryEvent' procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead.

Source Error:


Line 204:
Line 205: diaryDBConn.Open();
Line 206: sqlCmd.ExecuteNonQuery();
Line 207: mEventId = Convert.ToInt32(sqlCmd.Parameters["@NewEventId"].Value);
Line 208:


Thanks,
Trent
 
Old June 29th, 2007, 01:05 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Trent,

The error message seems to suggest you are inserting a value for the DiaryId column with no matching record in another table.

Right before you save the entry in the database, check out the object by setting a breakpoint. What values are you trying to pass? Do they match with the data your database is expecting?

Would you like to share your complete source with fellow readers of the book when everything works?

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old June 29th, 2007, 02:45 PM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I will look at your suggestions.

I am willing to share the source code. It would benefit me the most because I am doing this for a class project. I am not the best programmer and still learning C#. So maybe if someone could look at the code and give me some suggestions.

I currently have added other items, such as administration and master pages. As I said everything else is working expect for adding items to the database. If I add them manually in the table I am able to view and edit them.

How would I share this with others? The only way I now of is to Zip it up and email to someone.

Trent
 
Old August 5th, 2008, 09:01 AM
Registered User
 
Join Date: Aug 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

 Do you have maybe where I can download Online Diary in C# version ? I don't know VB, this strange for me ;/ Can You help translate this project ??

 
Old August 5th, 2008, 09:13 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,

Sorry, this app has not been translated yet. The only C# applications from the book can be found here: http://p2p.wrox.com/forum.asp?FORUM_ID=249

However, with an on-line converter like this one http://converter.telerik.com/ and some help from Google it shouldn't be too hard to do...

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old August 5th, 2008, 09:15 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

BTW you could try sending Trent an e-mail through his profile page: http://p2p.wrox.com/pop_profile.asp?...splay&id=65110

If he's willing to share the app, Wrox will provide links to it. Alternatively, it can be hosted on one of my own servers so others can download it as well.

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old August 5th, 2008, 09:37 AM
Registered User
 
Join Date: Aug 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi !

 Imar thx for you help, I will try translate it slowly by myself :) I'll use the tool you gave me link :)
Thanks!

 
Old August 5th, 2008, 10:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Good luck...

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Application similar to Online Diary gsrai31 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 April 19th, 2008 08:41 AM
Online Diary Problems gsrai31 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 April 17th, 2008 09:44 AM
ONline Diary Mod Question Mel64081 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 February 8th, 2007 05:18 PM
Online Diary - Profiles (Chapter 1) alineurope BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 January 17th, 2007 06:05 PM
Online Diary - works! mpremji BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 0 April 19th, 2006 06:13 PM





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