help pls.. easy question??

G

Guest

i just finished creating an asp.net application named teddybears.

during the testing phase uploaded live ( ex: www.teddy.com) , i tried to
purchase something and add it to my shopping cart.

then, i tried opening the application on a different client computer. I just
randomly checked the shopping cart and there i found the same items i added
to my cart on the first computer.

all i did using to add to my cart was session("cart").

how can i just save the contents of the current cart to the current machine
being used?

thanks a million guys!
 
M

Mark Rae

how can i just save the contents of the current cart to the current
machine
being used?

How are you adding cart data to the Session object...? Sounds very much like
you're using static variables...
 
G

Guest

hey Mark

Session("cart") is an array of prodID,desc,qty and amount.

I add an item by adding the prodID to the BearArray() and re assigning that
array to the Session("cart") variable. These all revolves in a class called
shoppingcart.vb

Is there something wrong with what im doin?
 
M

Mark Rae

Session("cart") is an array of prodID,desc,qty and amount.

No doubt, but how / where is it declared...?
I add an item by adding the prodID to the BearArray() and re assigning
that
array to the Session("cart") variable. These all revolves in a class
called
shoppingcart.vb

Is there something wrong with what im doin?

Impossible to tell until you actually show us your code...
 
G

Guest

Hi Mark,

here's the piece of the code:
---------------------------------------
on my cart.aspx page:
---------------------------------------

Dim ala As New ShoppingCart

If Not IsNothing(Session("shoppingcart")) Then
ala = Session("shoppingcart")
End If

Dim objCartItem As New cartitem
Dim intItems As Integer

objCartItem.itemcode = seqid
objCartItem.itemname = seqname
objCartItem.qty = Qty
objCartItem.ddate = eventDate
objCartItem.unitprice = unit
objCartItem.total = objCartItem.unitprice * objCartItem.qty

ala.addCartItem(objCartItem)
Session("cartcount") = ala.CountItemsinCart.ToString
Session("shoppingcart") = ala

----------------------------------------------------------
on Global.vb class:
----------------------------------------------------------
Public _ItemsinCart As New Collections.ArrayList

----------------------------------------------------------
on a separate class called ShoppingCart.vb :
----------------------------------------------------------
Public Structure cartitem

Public itemcode As String
Public itemname As String
Public ddate As DateTime
Public unitprice As Decimal
Public total As Decimal
Public coupon As String
Public grandtotal As Decimal
Public qty As Long
Public schedulecode As String
End Structure

Public Sub addCartItem(ByVal item As cartitem)
If Not isItemExists(item) Then
_ItemsinCart.Add(item)
End If
End Sub

Everything seems to be fine except when i try to open another browser on
another computer i get the same shopping cart items from the first computer.
Does this have something to do with in process or out process memory thing?

thanks
 
M

Mark Rae

Public _ItemsinCart As New Collections.ArrayList

There's your problem - that ArrayList will be shared by the entire
application. Create your ArrayList in Session_Start, and don't make it
Public.
 
G

Guest

Thanks Mark! i'll try this

but i read the other post one before this, so thanks again!
 
G

Guest

Hi again,

im having some problems in putting the arraylist at session_start in
global.asx,

so how do u exactly write it?
it doesnt recognize it if i write somethin like:
------------------------------------
Private _ItemsinCart As New Collections.ArrayList.ArrayList
------------------------------------

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
'Private _ItemsinCart As New Collections.ArrayList.ArrayList
Session("_ItemsinCart") = ""
Session("_CustomerInfo") = ""
Session("_BillingInfo") = ""
Session("_CreditCardInfo") = ""
End Sub

Thanks
 
M

Mark Rae

it doesnt recognize it if i write somethin like:

Private _ItemsinCart As New Collections.ArrayList.ArrayList

There's no point at all saying something like "it doesn't recognise it", or
"it doesn't work" or "it throws an error" unless you actually say why it
doesn't recognise it, what error you get etc...

so how do u exactly write it?

Not exactly sure, as I never go anywhere near VB.NET, but it's probably
something like:

Private _ItemsinCart As New System.Collections.ArrayList()
 
G

Guest

It actually says "Private is not valid on a local variable declaration"

any ideas ?

Thx!!
 
M

Mark Rae

It actually says "Private is not valid on a local variable declaration"

I just created a new VB.NET website, added a Global application class,
pasted your code, and let IntelliSense find and correct the error for me -
didn't you have that option...?

Anyway, change Private to Dim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

shopping cart problem 5
Help 1
pls help me ; vhdl; 0
Only one table shows up with the information 2
Looking for Suggestions 12
Help for a newbie 13
Help me, going live with a quiz 0
shopping cart concept 1

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top