Simple select issue

  • I will insert a record in the cart table.

    If the Shopper is logged on then i will insert the shopper guid, and I will also insert the sessionid.

    If the shopper is not logged on I will just insert the sessionID.

    My problem is when i do a select against the cart table i am receive mixed results.

    If the shopper is not logged on the everything looks normal, but when the shopper is logged on and does a insert everything still looks normal.

    Now when the shopper logs out all the record added to the cart table when the shopper was logged on are no longer available. However, if shopper logs on again then all of the records are available..

    Can someone tell by looking at this simple query if i am doing something wrong here.

    SELECT COUNT(*) as 'ItemCount'

    FROM [dbo].[utbCart] WITH(NOLOCK)

    WHERE (CartID = @CartID or ShopperID = @ShopperID);

    Thank you

    Dam again!

  • There's not enough information for us. What does a log in or log out mean? Where do you keep the data? You are getting the cartID or the sessionID, but not necessarily tying those to something in the login process.

  • You description mentions shopper guid and sessionID, but your query mentions ShopperID and CartID. Could you clear this up for us?

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • CREATE TABLE [dbo].[utbCart](

    [ID] [int] IDENTITY(1,1) NOT NULL,

    [CartID] [varchar](20) NULL,

    [ShopperID] [uniqueidentifier] NULL,

    [ProductID] [int] NOT NULL,

    [ReferenceName] [varchar](70) NULL,

    [Quantity] [tinyint] NOT NULL,

    [ModifiedDate] [datetime] NOT NULL,

    [UnitCost] [money] NULL,

    [ExtendedCost] AS ([UnitCost]*[Quantity]),

    [IsPreBuilt] [bit] NOT NULL,

    CONSTRAINT [PK_utbCart_ID] PRIMARY KEY CLUSTERED

    (

    [ID] ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    ) ON [PRIMARY]

    GO

    -------------------------------

    Basically I am allowing the shopper to insert items into the shopping cart with out creating a user account. So if the are inserting items into the cart and not logged in they can still purchase.

    However, if they add items to the cart with out being logged in, AND they decide to login all items will be visible as expected.

    Now if the add items while logged in and then decide to logout only the items they added while not logged in are visible.

    Dam again!

  • The CartID column is a stored id in a cookie and or the session in my .net application.

    The ShopperID column is the logged on membership Guid userID

    Dam again!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply