Hi All
I have a problem about CartID in ShoppingCart.aspx (from IBuySpy.com,the sample from
www.asp.net) Now, I can insert data from the selected product (in ProductDetail.aspx) to ShoppingCart Table that I set it in oracle9. By this code:
Public Sub AddItem(ByVal cartID As String, ByVal productID As String, ByVal quantity As Integer)
Dim myConnString As String = _
"user id=scott;integrated security=False;data source=orcl;password=tiger"
Dim myConnection As New OracleConnection(myConnString)
' Create Instance of Connection and Command Object
Dim myCommand As OracleCommand = New OracleCommand("SHOPPINGCARTADDITEM", myConnection)
' Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure
' *********************************************
' Add Parameters to SPROC
Dim parameterProductID As OracleParameter = New OracleParameter("I_ProductID", OracleType.VarChar, 4)
parameterProductID.Value = productID
myCommand.Parameters.Add(parameterProductID)
Dim parameterCartID As OracleParameter = New OracleParameter("I_CartID", OracleType.VarChar, 10)
parameterCartID.Value = cartID
myCommand.Parameters.Add(parameterCartID)
Dim parameterQuantity As OracleParameter = New OracleParameter("I_Quantity", OracleType.Number, 4)
parameterQuantity.Value = quantity
myCommand.Parameters.Add(parameterQuantity)
' Open the connection and execute the Command
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
End Sub
***************************
The value of field â CartIDâ is some character like this â553e23c8-3â That Iâm not understand in its meaning.
Public Function GetShoppingCartId() As String
' Obtain current HttpContext of ASP.NET Request
' UNDONE: fix this
Dim context As HttpContext = HttpContext.Current
' If the user is authenticated, use their customerId as a permanent shopping cart id
If context.User.Identity.Name <> "" Then
Return context.User.Identity.Name
End If
' If user is not authenticated, either fetch (or issue) a new temporary cartID
If Not context.Request.Cookies("ASPNETCommerce_CartID") Is Nothing Then
Return context.Request.Cookies("ASPNETCommerce_CartID").V alue
Else
' Generate a new random GUID using System.Guid Class
Dim tempCartId As Guid = Guid.NewGuid()
' Send tempCartId back to client as a cookie
context.Response.Cookies("ASPNETCommerce_CartID"). Value = tempCartId.ToString()
' Return tempCartId
Return tempCartId.ToString()
End If
End Function
*********************************
And this is a procedure for ShoppingCartList
(CARTID IN VARCHAR2)
As
PRD_PRODUCTID VARCHAR2(4);
PRD_PRODUCTTITLE VARCHAR2(50);
QUANTITY NUMBER(4);
PRD_UNITPRICE NUMBER(10,2);
EXTENEDAMOUNT NUMBER(10,2);
begin
SELECT TBLPRODUCT.PRD_PRODUCTID,TBLPRODUCT.PRD_PRODUCTTIT LE,
SHOPPINGCART.QUANTITY,
TBLPRODUCT.PRD_UNITPRICE,
TBLPRODUCT.PRD_UNITPRICE*SHOPPINGCART.QUANTITY
INTO
PRD_PRODUCTID,PRD_PRODUCTTITLE,QUANTITY,PRD_UNITPR ICE,EXTENEDAMOUNT
FROM
TBLPRODUCT,SHOPPINGCART
WHERE
TBLPRODUCT.PRD_PRODUCTID=SHOPPINGCART.PRODUCTID
AND
SHOPPINGCART.CARTID=CARTID
ORDER BY
TBLPRODUCT.PRD_PRODUCTTITLE;
end;
*********************************
But it doesnât show anything (like a data that is inserted into ShoppingCart Table) in datagrid of ShoppingCart.aspx. I then try to select the other product again and it shows error as the following.
ORA-01422: exact fetch returns more than requested number of rows ORA-06512: at "SCOTT.SHOPPINGCARTLIST", line 9 ORA-06512: at line 1
Have anyone know about this error?
Thanks in advance
Blueman137