Monday, February 20, 2012

Problem with Database: " No value given for one or more required parameters."

I am working on my first project, and using Visual Web Developer 2005, and I am having one heck of a time with one of my pages.

I am making a makeshift shoppingcart program for one of my classes, and I can't get the checkout page to work. All my other pages work just fine, and this is the only one that won't work.

I am hoping someone is able to help me

I am attaching what I think is causing the problem, hopefully someone might see something amiss:

These are my AccessDataSources
<asp:AccessDataSource ID="adsAddNewOrder" runat="server" DataFile="~/App_Data/GoalieStore.mdb" InsertCommand="INSERT INTO Orders(OrderID,CustomerID,SalesTaxRate,Shipping) VALUES (?,?,0.14,25)" SelectCommand="SELECT OrderID, CustomerID FROM Orders"></asp:AccessDataSource>
<asp:AccessDataSource ID="adsAddNewOrderDetails" runat="server" DataFile="~/App_Data/GoalieStore.mdb"
InsertCommand="INSERT INTO OrderDetails(ProductID,OrderID,Quantity) SELECT ProductID,OrderID,Quantity FROM Cart WHERE (CustomerID = ?)"
SelectCommand="SELECT ProductID, OrderID FROM OrderDetails"></asp:AccessDataSource>
<asp:AccessDataSource ID="adsClearCart" runat="server" DataFile="~/App_Data/GoalieStore.mdb"
DeleteCommand="DELETE * FROM Cart WHERE (CustomerID = ?)" SelectCommand="SELECT Cart.* FROM Cart">
</asp:AccessDataSource>

and I have VB.Net code as follows:
Protected Sub ClearCart()
'Create a Delete Query Parameter using a Session variable tag
Dim paramCID As New SessionParameter
paramCID.SessionField = "CustomerID"

adsClearCart.DeleteParameters.Clear() 'clear all existing Delete Query parameters
adsClearCart.DeleteParameters.Add(paramCID) 'add the Session variable Parameter
adsClearCart.Delete() 'run the query
End Sub

Protected Sub btnNewOrder_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim paramCID As New SessionParameter
paramCID.SessionField = "CustomerID"
Dim paramOID As New SessionParameter
paramOID.SessionField = "OrderID"
'add the parameters to the Order table Insert Query and run the Query
adsAddNewOrder.InsertParameters.Clear()
adsAddNewOrder.InsertParameters.Add(paramOID)
adsAddNewOrder.InsertParameters.Add(paramCID)
adsAddNewOrder.Insert()
'add the parameter to the OrderDetails table Insert Query and run the Query
adsAddNewOrderDetails.InsertParameters.Clear()
adsAddNewOrderDetails.InsertParameters.Add(paramCID)
adsAddNewOrderDetails.Insert()
'Clear Cart
ClearCart()
Server.Transfer("confirm.aspx")
End Sub


The user presses a button to confirm there order, and thats when I get the error "No Value given for one or more required parameters."


Hope someone can help!
Thanks,
Greg

As you said that is a problem from confirm.aspx

http://forums.asp.net/thread/1472678.aspx

Thanks

No comments:

Post a Comment