Print Page | Close Window

What's Wrong with This Code?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=20026
Printed Date: 28 March 2026 at 2:20pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: What's Wrong with This Code?
Posted By: davidshq
Subject: What's Wrong with This Code?
Date Posted: 25 May 2006 at 3:29am
I am working on a new ASP.NET 2.0 application. I have a stored procedure as follows that is giving me some grief:
ALTER PROCEDURE dbo.LeaveFeedback
   
    (
    @varUser varchar(max),
    @varID int,
    @varFeedback text,
    @varFeedbackLeftFor varchar(max),
    @varPositiveOrNegative int,
    @varOfferer varchar(max),
    @varIsRCom int,
    @varIsOCom int
    )

   
AS
    /* SET NOCOUNT ON */
    INSERT INTO UserFeedback (UserName, Feedback, PosNeg, Item, LeftBy) VALUES (@varFeedbackLeftFor, @varFeedback, @varPositiveOrNegative,
    @varID, @varUser)

    SET @varOfferer=(select offerer from AvailableFeedback where Item=@varID)
    If @varOfferer=@varUser
    BEGIN
    UPDATE AvailableFeedback set OffererComplete=1 where Item=@varID
    END
    Else
    BEGIN
    UPDATE AvailableFeedback set RequestorComplete=1 where Item=@varID
    END

    SET @varIsRCom=(select RequestorComplete from AvailableFeedback where Item=@varID)
    SET @varIsOCom=(select OffererComplete from AvailableFeedback where Item=@varID)
    If @varISOCom=1 AND @varISRCom=1
    BEGIN
    DELETE FROM AvailableFeedback where Item=@varID
    END
   
    RETURN

The code is divided into several blocks:
1. Variable declarations.
2. Add feedback to feedback table.
3. Determine whether it was the offerer or requestor who left the feedback, and update the field that notes whether they left feedback.
4. If both offerer and requestor have left feedback, delete the entry from the table so that they can't leave multiple feedback on the same item.
   Now, the adding of the feedback works fine, but it fails to get past this point. Any ideas why?
David.


-------------
- http://www.davemackey.net/" rel="nofollow - Dave Mackey - Virtual Home.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net