beccatigger Posted January 29, 2005 Posted January 29, 2005 Hi, another problem with my Charon cartI've got to the checkout and I can add my order details (OrderID etc etc)My tables in ms access are the following:Orders table:OrderID(primary key created during asp coding)OrderDetails table:OrderDetailsID (autonumber, primary key)OrderID (text, linked one to many with Orders.OrderID)etc etcWhen I try to do the function on the page, it will only add the OrderID to the OrderDetails table if it's the OrderDetails field is set to text and it's the primary key! (Thus removing the relationship between the two tables)Have also allowed session variables in my browser<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%><!--#include file="inc_CharonCart.asp" --><script language="javascript" runat="server">function GetTimeInMillisec(){ var Now = new Date() var TimeStamp = Now.getTime() return TimeStamp}</script><!--#include file="Connections/searching.asp" --><%Dim Recordset1__varRecordset1__var = "1"If (CCcart_Subtotal <> "") Then Recordset1__var = CCcart_SubtotalEnd If%><%Dim Recordset1Dim Recordset1_numRowsSet Recordset1 = Server.CreateObject("ADODB.Recordset")Recordset1.ActiveConnection = MM_searching_STRINGRecordset1.Source = "SELECT * FROM postage WHERE MinCost <= " + Replace(Recordset1__var, "'", "''") + " AND MaxCost > " + Replace(Recordset1__var, "'", "''") + ""Recordset1.CursorType = 0Recordset1.CursorLocation = 2Recordset1.LockType = 1Recordset1.Open()Recordset1_numRows = 0%><%Dim rsOrdersDim rsOrders_numRowsSet rsOrders = Server.CreateObject("ADODB.Recordset")rsOrders.ActiveConnection = MM_searching_STRINGrsOrders.Source = "SELECT top 1 OrderID, SubTotal, PP, GrandTotal FROM Orders"rsOrders.CursorType = 0rsOrders.CursorLocation = 2rsOrders.LockType = 3rsOrders.Open()rsOrders_numRows = 0%><%Dim rsOrderDetailsDim rsOrderDetails_numRowsSet rsOrderDetails = Server.CreateObject("ADODB.Recordset")rsOrderDetails.ActiveConnection = MM_searching_STRINGrsOrderDetails.Source = "SELECT top 1 OrderID, ProductID, ProductName, UnitPrice, Quantity FROM OrderDetails"rsOrderDetails.CursorType = 0rsOrderDetails.CursorLocation = 2rsOrderDetails.LockType = 3rsOrderDetails.Open()rsOrderDetails_numRows = 0%><%''Add shipping from a value in a recordset'The recordset may be pre-filtered based on the CCcart_SubTotal value'if not Recordset1.eof thenCCcart_Shipping=Recordset1("PostCost")end if%><% ''Insert record into Orders recordset when form is submitted'and store the unique OrderID'CC_OrderAction=Request.ServerVariables("SCRIPT_NAME")if Request("CC_OrderInsert") <> "" thenTimeKey=GetTimeInMillisec()rsOrders.AddNewrsOrders("OrderID")=TimeKeyFor Each fld in rsOrders.Fieldsif Len(Request(fld.Name)) > 0 thenfld.Value = Request(fld.Name)end ifNextrsOrders.UpdatersOrders.RequeryrsOrders.Filter= "OrderID='" & TimeKey & "'"if rsOrders.eof = false then Session("OrderID")end if%><%''**Save cart to OrderDetails table in Database**'if Request("CC_OrderInsert") <> "" then'Bindingvalues=("ProductID,Quantity,ProductName,UnitPrice,")UniqueIdValue=Session("OrderID") UniqueIdColumn="OrderID"CC_RedirectURL="checkout2.asp"sub SaveToDatabase(ODRecordset)ODRecordset.AddNewODRecordset.Fields(UniqueIdColumn)=UniqueIdValueODRecordset.Fields("ProductID")=CCcart(CC_ProductID,i)ODRecordset.Fields("Quantity")=CCcart(CC_Quantity,i)ODRecordset.Fields("ProductName")=CCcart(CC_Name,i)ODRecordset.Fields("UnitPrice")=CCcart(CC_Price,i)rsOrderDetails.Updateend subfor i=0 to ubound(CCcart,2)if CCcart(CC_ProductID,i) <> "" thenCall SaveToDatabase(rsOrderDetails)end ifnextResponse.Redirect "search2.asp"end if%>rsOrders gets the OrderID from OrdersrsOrderDetails gets all the fields from OrderDetails (except for OrderDetailID as it's an autonumber)If anyone could help me out as to why it will only allow it when it's in the OrderDetailsID field that would be great.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now