Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problems with data

Problems with data

Scheduled Pinned Locked Moved ASP.NET
databasesaleshelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TAK78
    wrote on last edited by
    #1

    I have a database in which I store the items that a customer added to the shoppingcart. Now I try to get the data and put it into the shoppingcart when the user loggs back in and there were items he didn't purchased yet but left in cart last time he was logged. It will display the right quantity of each product, but it shows the Name and price of last recieved product in my ShoppingCart display on all products. Here is code I have so far for getting items from DB and adding to ShoppingCart: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Membership.GetUser() Is Nothing Then StoreManager.ShoppingCart.UserID = Membership.GetUser().UserName If Not Session("Logged") Then StoreDB.GetShoppingCart(Membership.GetUser().UserName) Session("Logged") = True End If Else HttpContext.Current.Session("ShoppingCart") = New ShoppingCart() StoreManager.ShoppingCart.UserID = "" Session("Logged") = False End If End Sub Public Shared Sub GetShoppingCart(ByVal userID As String) Try Using myCon As New SqlConnection(AppConnection.ConnectionString) Dim myCom As SqlCommand = New SqlCommand("sprocGetShoppingCartItems", myCon) myCom.CommandType = CommandType.StoredProcedure myCom.Parameters.AddWithValue("@cartID", userID) Dim prod As Product = New Product Dim qty As Integer = 0 myCon.Open() Using myRd As SqlDataReader = myCom.ExecuteReader(CommandBehavior.CloseConnection) While myRd.Read() prod.CategorieID = myRd.GetInt32(myRd.GetOrdinal("CategorieID")) prod.ProductID = myRd.GetInt32(myRd.GetOrdinal("ProductID")) prod.ProductName = myRd.GetString(myRd.GetOrdinal("ProductName")) prod.ProductPrice = myRd.GetDecimal(myRd.GetOrdinal("ProductPrice")) prod.ProductMini = myRd.GetString(myRd.GetOrdinal("ProductImage")) prod.Qty = myRd.GetInt32(myRd.GetOrdinal("Quantity")) MsgBox("Adding: " & prod.ProductName) StoreManager.ShoppingCart.AddDB(prod, prod.Qty) End While myRd.Close() End Using End Using Catch ex As Exception ' error

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups