Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8412495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:41:00+00:00 2026-06-10T00:41:00+00:00

I have these three tables [ Orders, order_Items, order_comment ] | -Orders- | |

  • 0

I have these three tables [ Orders, order_Items, order_comment ]

|    -Orders-    |     |  -Order_Items-   |     | -Order_comment- |
|    order_id    |     |  order_RegCode   |     |    order_id     |
| order_RegCode  |

As you can see, these three tables related together by 2 unique key! order_id and order_RegCode.

P.s: order_RegCode is not Primary Key and is a String!

i want when i delete any order by order_id, delete all related information that stored in two others tables. But when i using Do While i got error Operation is not allowed when the object is closed.

please guide me.

The Code is:

Dim Order_ID
    Order_ID = Int(Request.Form("ID"))

Set Conn = server.createobject("adodb.connection")
Conn.open StrConn
Set Rs = Conn.execute("SELECT * From orders WHERE order_id="& Order_ID &"")
If NOT Rs.EOF then

    RegCode = Rs("order_RegCode")

    '//== Delete Order
    Set Rs = Conn.execute("Delete From orders where order_id = "& orderID &"")

    '//== Delete All Comments Belong to Order
    Set Rs = Conn.execute("Select * From order_comment where order_id = "& Order_ID &"")
    If NOT Rs.EOF then
        Do While NOT Rs.EOF
            Set Rs = Conn.execute("Delete From order_comment where order_id = "& Order_ID &"")
        Rs.MoveNext
        Loop
    End if

    '//== Delete All Items Belong to Order
    Set Rs = Conn.execute("Select * From order_items where order_code = '"& RegCode &"'")
    If NOT Rs.EOF then
        Do While NOT Rs.EOF
            Set Rs = Conn.execute("Delete From order_items where order_code = '"& RegCode &"'")
        Rs.MoveNext
        Loop
    End if

End if
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:41:01+00:00Added an answer on June 10, 2026 at 12:41 am

    You must not use a recordset for action queries. These lines:

    Set Rs = Conn.execute("Delete ...
    

    Should be:

    Conn.execute("Delete ...
    

    You cannot use the same object for all recordsets. You will need a recordset for the outer loop and another for the inner loop. However, I suggest:

    Dim Order_ID
    Order_ID = Int(Request.Form("ID"))
    
    Set Conn = server.CreateObject("adodb.connection")
    Conn.Open StrConn
    Set rs = Conn.Execute("SELECT * From orders WHERE order_id=" & Order_ID)
    If Not rs.EOF Then
    
        RegCode = rs("order_RegCode")
    
        '//== Delete Order
        Conn.Execute ("Delete From orders where order_id = " & orderID)
        Conn.Execute ("Delete From order_comment where order_id = " & Order_ID)
        Conn.Execute ("Delete From order_items where order_code = '" & RegCode & "'")
    
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables (lots in reality but these three are the ones I
I have users table. There are three other tables: developers, managers, testers. All of
i have three tables: A, B and C, B is the table necessary to
Well guys, I have three tables here, menu, user and access. For simplifying let's
I have three tables that are joined. I almost have the solution but there
My goal is to get a query written. I have three tables, A, B
I have a MySQL table that represents a list of orders and a related
I have an item-to-item similarity matrix set up with these tables: items (id, ...)
I have the following tables: Orders, Notes, Permits The following columns are in each
I have a simple web application with database tables orders and products that I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.