-3
我正在開發一個在線購物網站..因此,當用戶將任何物品添加到購物車時,我將它存儲在一張桌子中......現在我想要的是計算購物車中的物品以及每次用戶添加新物品時都會更新購物車中的物品數量....如何計算購物車中物品的數量
請幫助我...我對asp.net非常陌生。
Public Function AddToCart(ByVal itemID As String, ByVal itemName As String, ByVal itemPrice As Integer, _
ByVal offer As String, ByVal buyNo As String, ByVal userID As String) As String
Dim sqlStatement As String = "INSERT INTO shoppingCart" & _
"(buyNo, userID, itemID, itemName, itemPrice, offer, itemQtty)" & _
"VALUES('" & buyNo & "','" & userID & "','" & itemID & "','" & itemName & "'," & itemPrice & ",'" & offer & "'," & _
"1)"
Dim connStr As String = ConfigurationManager.ConnectionStrings("databaseConnectionString").ConnectionString
Dim con As New SqlClient.SqlConnection(connStr)
'Dim con As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;" & _
' "AttachDbFilename=|DataDirectory|\database.mdf;" & _
' "Integrated Security=True;User Instance=True")
Dim sql As New SqlClient.SqlCommand(sqlStatement, con)
con.Open()
sql.ExecuteNonQuery()
con.Close()
con.Dispose()
MsgBox("Item with 'Item ID: " & itemID & "' & 'Item Name: " & itemName & _
"' has been added to the cart!")
Dim sno As Integer = CType(Replace(buyNo, userID, ""), Integer)
sno = sno + 1
buyNo = userID & sno
Return buyNo
End Function
如果您是新手,最好使用完整文檔附帶的盒子。 – 2011-06-12 13:03:34
請顯示您的代碼。 – Predator 2011-06-12 13:04:31
你介意幫我嗎??? – Monodeep 2011-06-12 13:04:46