Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 21st, 2005, 02:41 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default Inserted Rows Doubling up on Dataset Updates

I'm posting this again because I think I have more information now, and I also think my 2 mile long post may have intimidated some folks. Sorry, no more source code in my posts (I put a link to it on the website example).

The Calendar Application is posted here:

http://www.datasushi.net/Calendar/Calendar2.aspx

The problem with it is when you add new appointments:
1) If you just add one appointment no problem.
2) However if you add a second new appointment, it adds it to the database, but it also adds the first one a second time, so you wind up with three new appointments.

(if you then went to add yet another appointment, you'd wind up with 7 new appointments - it always adds what you're intending to add, plus everything else that's been added)

You won't see this problem until you close your browser and re-open it, and go back to the website. That is because the page loads the full dataset and stores it in the session object, it only loads from the database if the session variable is not set.

I'm pretty sure the problem is the how I'm dealing with the dataset updates. Somehow I need to tell it, after I update the inserted rows, that those rows are no longer "inserted", and can be ignored on the next update. Not sure how to do that.

Thanks.

Aaron

 
Old July 21st, 2005, 04:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

OK, well I don't use this (update) method with datasets so what I suggest may have an easier solution. Also, I just briefly looked at your code so I may have missed something.

However, how about utilizing your dataset with 2 tables, one to hold all of the values of the calendar and one that will hold the value you wish to insert. After inserting, you can copy the row to the other table, then clear the row from the insert table. This should stop it from duplicating and also update the other table without making a call to the database for the new row addition. Of course you would have to ensure that the data was inserted into the database.

J
 
Old July 21st, 2005, 04:42 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. I actually figured it out (with the help of another poster on a different forum).

After doing the update to the dataset, I needed to call ds.AcceptChanges. I thought I'd tried that, but it turns out I'd only tried ds.Tables(0).AcceptChanges, which didn't work.

Ater Accepting changes in the dataset, I needed to put it back into the session. It seems to work now.

Thanks.

Aaron


 
Old July 21st, 2005, 06:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Yes, as I said, I assumed there was an easier way...





Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I get the last inserted rows? fraijo SQL Server 2000 4 November 23rd, 2006 07:50 AM
Fetching rows in dataset lily611 C# 4 April 27th, 2006 12:37 AM
NullReferenceException updating a DataSet rows yoord BOOK: Beginning ASP.NET 1.0 7 September 1st, 2004 03:49 PM





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