| |
|||
Первым делом следует удостовериться, что на страницу передан ID товара:
("Select ProductName, LongDescription, " _ & "PathToIcon, PathToFull, Price, CategoryName " _ & "From Products Left Join ProductCategories On " & "Products.ProductCategorylD = " _ & "ProductCategories.ProductCategorylD Where " _ & "ProductID = " & Request.QueryString("ProductID") _ , DBConn)
"ProductData")
& DSPageData.Tables("ProductData"). _ Rows(0).Item("ProductName") & "</CENTER>"
& DSPageData.Tables("ProductData"). _ Rows (0) .Item("CategoryName")
Rows(O) .Item("PathToIcon")
Rows(O) .ItemC'PathToFull")
Rows(0).Itern("LongDescription")
& FormatCurrency(DSPageData.Tables("ProductData"). _ Rows(O).Item("Price"))
Dim DBConn as OleDbConnection Dim DBInsert As New OleDbCommand Dim DBCommand As OleDbDataAdapter Dim DSPageData as New DataSet Dim CurrentQuantity as Integer Dim CurrentPrice as Single Dim CurrentShipping as Single Dim CurrentProductName as String DBConn = New OleDbConnection("Provider=sqloledb;" _ & "server=localhost;" _ & "Initial Catalog=INETC15;" _ & "User Id=sa;" _ S "Password=(yourpassword;") DBInsert.Connection = DBConn DBInsert.Connection.Open If Len(Session("CustomerlD")) = 0 Then DBInsert.CormnandText = "Insert Into Customers " _ & "(Status, DateEntered) values ('Shopping', '" _ & Now ()&"')" DBInsert.ExecuteNonQuery() DBCommand = New OleDbDataAdapter _ ("Select Max(CustomerlD) as MaxID " _ & "From Customers", DBConn) DBCommand.Fill(DSPageData, _ "CustomerlD") Session("CustomerlD") = DSPageData.Tables("CustomerlD"). _ Rows(0).Item("MaxID") End If DBCommand = New OleDbDataAdapter _ ("Select ProductName, ShippingCharge, " _ 5 "Price From Products Where " _ 6 "ProductID = " & Request.QueryString("ProductID") _ , DBConn) DBCommand.Fill(DSPageData, _ "ProductData") CurrentQuantity = txtQuantity.Text CurrentPrice = CurrentQuantity * _ DSPageData.Tables("ProductData"). _ Rows(O).Item("Price") CurrentShipping = CurrentQuantity * _ DSPageData.Tables("ProductData"). _ Rows(O).Item("ShippingCharge") CurrentProductName = DSPageData.Tables("ProductData"). _ Rows (0) .Item,("ProductName") DBInsert.CommandText = "Insert Into ShoppingCartltems " _ & "(CustomerlD, ProductName, Quantity, Price, Shipping) " _ & "values (" _ & Session("CustomerlD") & ", " _ & "'" & CurrentProductName & "', " _ & CurrentQuantity & ", " _ & CurrentPrice & ", " _ & CurrentShipping & ")" DBInsert.ExecuteNonQuery() Response.Redirect("./shopping_cart.aspx") End Sub |
|||