|
Доступ к акцесовской базе
#33416055
Ссылка:
Ссылка на сообщение:
Ссылка с названием темы:
Ссылка на профиль пользователя:
|
Участник
Откуда: Краснодар
Сообщения: 155
|
|
Вот код обработчика нажатия кнопки
После его прохождения постоянно появляется ошибка "Невозможно использовать ''; файл уже используется"
Просьба не кидать камнями я новичок 8-)
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59.
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
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=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" & Server.MapPath("./base.mdb;"))
DBInsert.Connection = DBConn
DBInsert.Connection.Open
If Len(Session("CustomerID")) = 0 Then
DBInsert.CommandText = "Insert Into Customers " _
& "(Status, DateEntered) values ('Shopping', '" _
& Now() & "')"
DBInsert.ExecuteNonQuery()
DBInsert.Connection.close
DBCommand = New OleDbDataAdapter _
("Select Max(CustomerID) as MaxID " _
& "From Customers", DBConn)
DBCommand.Fill(DSPageData, _
"CustomerID")
Session("CustomerID") = DSPageData.Tables("CustomerID"). _
Rows( 0 ).Item("MaxID")
End If
DBCommand = New OleDbDataAdapter _
("Select ProductName, ShippingCharge, " _
& "Price From Products Where " _
& "ProductID = " & Request.QueryString("ProductID") _
, DBConn)
DBCommand.Fill(DSPageData, _
"ProductData")
CurrentQuantity = txtQuantity.Text
CurrentPrice = CurrentQuantity * _
DSPageData.Tables("ProductData"). _
Rows( 0 ).Item("Price")
CurrentShipping = CurrentQuantity * _
DSPageData.Tables("ProductData"). _
Rows( 0 ).Item("ShippingCharge")
CurrentProductName = DSPageData.Tables("ProductData"). _
Rows( 0 ).Item("ProductName")
DBInsert.CommandText = "Insert Into ShoppingCartItems " _
& "(CustomerID, ProductName, Quantity, Price, Shipping) " _
& "values (" _
& Session("CustomerID") & ", " _
& "'" & CurrentProductName & "', " _
& CurrentQuantity & ", " _
& CurrentPrice & ", " _
& CurrentShipping & ")"
DBInsert.Connection.close
Response.Redirect("./check_out.aspx")
End Sub
|
|
|