CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Shpping cart Insert in to order table

Print topic Send  topic

Author Message
softmafia

Posts: 44
Posted: 01/17/2005, 4:09 AM

I designed a shopping cart from the example shopping cart that came with CSS if i click the to purchase link it gives me this error can some one help me debug it


This Is the Error'

Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
/go4adeal/shop_cart_events.asp, line 70


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

Page:
POST 34 bytes to /go4adeal/shop_cart.asp

POST Data:
purchase=Click+here+to+Place+Order

Time:
Tuesday, December 21, 2004, 1:10:22 PM



This Is the Event Code
<%
'BindEvents Method @1-AC9034F6
Sub BindEvents()
Set shop_cart.CCSEvents("BeforeShowRow") = GetRef("shop_cart_BeforeShowRow")
Set shop_cart.CCSEvents("BeforeShow") = GetRef("shop_cart_BeforeShow")
Set purchase.purchase.CCSEvents("OnClick") = GetRef("purchase_purchase_OnClick")
End Sub
'End BindEvents Method

Function shop_cart_BeforeShowRow() 'shop_cart_BeforeShowRow @7-C5C30ACF

'Custom Code @28-73254650
' -------------------------
shop_cart.SubTotal.value = shop_cart.Price.value * shop_cart.Quantity.value
' -------------------------
'End Custom Code

End Function 'Close shop_cart_BeforeShowRow @7-54C34B28

Function shop_cart_BeforeShow() 'shop_cart_BeforeShow @7-6708AD50

'Custom Code @29-73254650
If shop_cart.Recordset.EOF Then
shop_cart.Visible = False
shop_total.Visible = False
purchase.Visible = False
Else
cart_is_empty.Visible = False
End If
'End Custom Code

End Function 'Close shop_cart_BeforeShow @7-54C34B28

Function purchase_purchase_OnClick() 'purchase_purchase_OnClick @39-1E2159D3

'Custom Code @40-73254650
Dim order_date
Dim last_order_id
Dim RecordSet
Dim SQL
Dim OrderTotal

' Count Order Total
SQL = "SELECT SUM(price*quantity) as total " _
& "FROM shopping_cart_items a, products b " _
& "WHERE a.product_id=b.product_id and " _
& "shopping_cart_id =" & DBdeal.ToSQL(Request.Cookies("shopping_cart_id"),ccsInteger)
Set RecordSet = DBdeal.Execute(SQL)
OrderTotal = CCGetValue(RecordSet, "total")

' Create a new order
SQL="INSERT INTO orders (order_date, order_status_id, total) VALUES (" _
& DBdeal.ToSQL(Now(),ccsDate) & ",1," _
& DBdeal.ToSQL(OrderTotal,ccsFloat) & ")"
DBdeal.Execute(SQL)

'Get Order ID
'This method compatible with all databases (unsafe when multiple users insert records at the same time)
'Use your own method for your database.
SQL = "SELECT MAX(order_id) FROM orders"
Set RecordSet = DBdeal.Execute(SQL)
last_order_id = CCGetValue(RecordSet, 0)

'Move items from user's shopping cart into the order
SQL = "SELECT a.product_id as product_id, a.quantity as quantity, price " _
& "FROM shopping_cart_items a, products b " _
& "WHERE a.product_id=b.product_id AND shopping_cart_id = " & DBdeal.ToSQL(Request.Cookies("shopping_cart_id"),ccsInteger)
Set RecordSet = DBdeal.Execute(SQL)
/// here is where the error is coming from
While NOT Recordset.EOF
SQL = "INSERT INTO order_items (order_id, product_id, quantity, price ) " _
& "VALUES (" & DBdeal.ToSQL(last_order_id,ccsInteger) _
& "," & DBdeal.ToSQL(CCGetValue(RecordSet, "product_id"),ccsInteger) _
& "," & DBdeal.ToSQL(CCGetValue(RecordSet, "quantity"),ccsInteger) _
& "," & DBdeal.ToSQL(CCGetValue(RecordSet, "price"),ccsFloat) _
& ")"
DBdeal.Execute(SQL)
Recordset.MoveNext
Wend

'Delete items from user's shopping
DBdeal.Execute("DELETE FROM shopping_cart_items WHERE shopping_cart_id = " & DBdeal.ToSQL(Request.Cookies("shopping_cart_id"),ccsInteger) )

'End Custom Code

End Function 'Close purchase_purchase_OnClick @39-54C34B28


%>
_________________
softmafia
View profile  Send private message
peterr


Posts: 5971
Posted: 01/17/2005, 9:29 AM

I suspect that the SQL query didn't return anything (0 records).
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
JerryVT
Posted: 01/17/2005, 10:31 AM

I had the same problem with 0 records returned when I used Project's DB connection.
Tried everything and made it work only with a newly created ADODB connection.

I think that I 've seen another post about troubles with using Project's Connection.
softmafia

Posts: 44
Posted: 01/17/2005, 10:51 AM

Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
/go4adeal/shop_cart_events.asp, line 70


what does it mean to say Object is closed??
_________________
softmafia
View profile  Send private message
peterr


Posts: 5971
Posted: 01/17/2005, 11:08 AM

I just checked and this means that the SQL is invalid - the query wasn't executed at all and returned an error. You may want to print the error message as shown at http://docs.codecharge.com/studio/html/ProgrammingTechn...eCustomSQL.html
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
peterr


Posts: 5971
Posted: 01/17/2005, 11:09 AM

Jerry,
I meant that the SQL was bad, not the connection.
Similar code works without problems in CCS store example.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
JerryVT
Posted: 01/17/2005, 2:14 PM

Thanks Peter,

In my case it wasn't SQL at all.

Most of the times project connection works OK but in 2 cases it was working flaky - ~ 8 out of 10 clicks were me giving that error.
I have decided to check for DBConnection.State upon calling project's connection and found the problem.
As I said, I created a new connection & errors have stopped.

I'd try to see if connection is OK first:
Response.write DBdeal.State ''''''''''''''''''''' ( 0 - closed, 1- opened)
Response.end
softmafia

Posts: 44
Posted: 01/18/2005, 6:20 AM

Peterr
you said the sql was bad but this is exactly the same code that worked in your shopping cart exam the code is exactly the same so the question is why is it not working?
ok can you please advice me on what to do please i am stock.
_________________
softmafia
View profile  Send private message
softmafia

Posts: 44
Posted: 01/18/2005, 7:16 AM

Peterr
I have debuged it and its working right now but i still have 2 problems its inserting into ORDER_ITEMS table but it is not inserting into the ORDER table please go through my 1st script and let me know wats was wrong
_________________
softmafia
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.