 |
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
|
|
|
|
|

October 20th, 2007, 11:26 AM
|
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
sprocApplicationInsertUpdateSingleItem
i don't understand this part of the stored procedure
ELSE
BEGIN
IF NOT EXISTS (SELECT 1 FROM Application WHERE Description = @description AND Id <> @id)
BEGIN
UPDATE Application SET
Description = @description,
IsActive = @isActive
WHERE Id = @id
SELECT @returnValue = @id
END
ELSE
BEGIN
SELECT @returnValue = -1 -- item already exists
END
END
are we making sure that there are no dup record by using the AND Id <> @id? what if we have dups?
|
|

October 20th, 2007, 12:10 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Yes correct. This code checks that the new Description of the item being updated does not conflict with an existing one. Since updating itself is fine, should should check for Id <> @id to filter all records other than the current one being updated.
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
|
|

October 20th, 2007, 06:03 PM
|
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok thanks I got it
|
|

October 21st, 2007, 02:43 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
I am not sure what you are asking. Why would there be a duplicate record? The whole idea in the procedure, for Insert and Updates is to prevent them in the first place.....
Can you elaborate a little bit??
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
|
|

October 21st, 2007, 04:43 AM
|
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry Imar I was confused about the way you wrote the stored procedure but now I'm not. But I still want know one thing, why you used the sp's return value to return the id? why not using an output parameter?
|
|

October 21st, 2007, 07:51 AM
|
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok thanks
|
|
 |