ERROR: Thread was being aborted ... Please Help!

i have this code wich works fine with 20-30 records but, if i use it with 120 records or more i get the "Thread was being aborted" error! what's happening? here's the code:

            //****************************************************************************
            //1 - Closes order
            private void closeOrder()
            {
                  //OrderType: collectInCustomer || deliverToCustomer      
                  if(orderType.Value.Trim() == "collectInCustomer")
                  {
                        //collectInCustomer » Stored
                        __mediaLocationStateFlags = "Stored";
                  }
                  else
                  {
                        //deliverToCustomer » IntheCustomer
                        __mediaLocationStateFlags = "IntheCustomer";
                  }
 
//                  Response.Write("status: " + __mediaLocationStateFlags +
//                        "<br>OrderID: " + _orderID);

                  
                  SqlConnection conn = new SqlConnection(_getSetting.mssqlsConn);
                  //[ 1 ] ....................................................................
                  //Selects Current order items - Loop
                  strCommand = "/* [ 1 ] Lists order media items - processOrder.aspx */ \n" +
                        "select * from EAD_ORDERS where OrderId = " + _orderID + "\n";

                  try
                  {
                        conn.Open();

                        SqlCommand cmd = new SqlCommand(strCommand,conn);
                        SqlDataReader reader = cmd.ExecuteReader();

                        while(reader.Read())
                        {
                              //Response.Write("item: " + reader["mediaID"].ToString() + "<br>");
                              closeOrderExec(Convert.ToInt32(reader["OrderID"].ToString().Trim()),
                                    Convert.ToInt32(reader["mediaID"].ToString().Trim()),
                                    __mediaLocationStateFlags);
                        }
                        reader.Close();
                  }

                  catch(Exception ex)
                  {
                        conn.Close();
                Response.Redirect("message.aspx?message=Erro closeOrder: " + Server.UrlEncode(ex.Message.ToString()));
                  }

                  finally
                  {
                        if (conn.State == ConnectionState.Open)
                              conn.Close();
                  }


                  //Order confirmation alert box - order processed ok
                  Page.RegisterStartupScript("orderProcessed",
                        "<script>\n" +
                        "alert('Pedido fechado com sucesso.'); \n" +
                        "location.href='processOrder.aspx?orderID=" + _orderID +
                        "&filter=Processed&orderType=" + _orderType + "';\n" +
                        "</script>\n");


//                        "location.href='listOrders.aspx?" + _orderID +
//                        "&filter=Processed'; \n" +
            }



            //******************************************************************************
            //2 - closeOrderExec
            private void closeOrderExec(int OrderID, int mediaID,
                  string __mediaLocationStateFlags)
            {
                  
                  SqlConnection conn = new SqlConnection(_getSetting.mssqlsConn);
                  conn.Open();

                  SqlCommand myCommand = conn.CreateCommand();
                  SqlTransaction myTrans;

                  myTrans = conn.BeginTransaction();
                  myCommand.Connection = conn;
                  myCommand.Transaction = myTrans;

                  try
                  {
                        //EAD_ORDERS
                        //Updates order state: OrderState from open to Processed
                        myCommand.CommandText = "/* [ 1.1 ] EAD_ORDERS - OrderState from open to Processed */ \n" +
                              "update EAD_ORDERS set OrderState = 'Processed', \n" +
                              "processingTimeStamp = getDate() \n" +
                              "where OrderID = " + OrderID + " \n";

                        //reader["OrderID"].ToString().Trim()
                        myCommand.ExecuteNonQuery();


                        //EAD_MEDIA_MASTER
                        //updates by referencing mediaID, columns MediaLocationState & oficialMediaLocationState
                        myCommand.CommandText = "/* [ 1.2 ] EAD_MEDIA_MASTER - Change MediaLocationState & oficialMediaLocationState */ \n" +
                              "update EAD_MEDIA_MASTER set MediaLocationState = '" + __mediaLocationStateFlags + "', \n" +
                              "oficialMediaLocationState = '" + __mediaLocationStateFlags + "' \n" +
                              "where mediaID = " + mediaID + " \n";
                        //reader["mediaID"].ToString().Trim()
                        myCommand.ExecuteNonQuery();

                        //myCommand.ExecuteNonQuery();
                        myTrans.Commit();
                  }

                  catch(Exception ex)
                  {
                        myTrans.Rollback();
                        conn.Close();
                Response.Redirect("message.aspx?message=Erro closeOrderExec: " + Server.UrlEncode(ex.Message.ToString()));
                  }

                  finally
                  {
                        if (conn.State == ConnectionState.Open)
                              conn.Close();
                  }

            }


i've tried messing with memory settings everywhere, machine.config....everything!!! can someone help me with this?
LVL 1
xjpmauricioAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

WelkinMazeCommented:
0
xjpmauricioAuthor Commented:
i tried that but the problem is that no data get's on the SQL server, it's like the queries in the private void closeOrderExec method don't get executed!
0
xjpmauricioAuthor Commented:
this is a sql server related problem, not a response.redirect problem i think! ...
0
yokkuiCommented:
Use Int32.ToString() for the parameters and HttpResponse(message, false) so that the current page won't stop the execution before the db connection is closed.

Try this:

...preceding code...

 try
               {
                    //EAD_ORDERS
                    //Updates order state: OrderState from open to Processed
                    myCommand.CommandText = "/* [ 1.1 ] EAD_ORDERS - OrderState from open to Processed */ \n" +
                         "update EAD_ORDERS set OrderState = 'Processed', \n" +
                         "processingTimeStamp = getDate() \n" +
                         "where OrderID = " + OrderID.ToString() + " \n";

...code...

                    myCommand.CommandText = "/* [ 1.2 ] EAD_MEDIA_MASTER - Change MediaLocationState & oficialMediaLocationState */ \n" +
                         "update EAD_MEDIA_MASTER set MediaLocationState = '" + __mediaLocationStateFlags + "', \n" +
                         "oficialMediaLocationState = '" + __mediaLocationStateFlags + "' \n" +
                         "where mediaID = " + mediaID.ToString() + " \n";
                    //reader["mediaID"].ToString().Trim()
                    myCommand.ExecuteNonQuery();

                    //myCommand.ExecuteNonQuery();
                    myTrans.Commit();
               }

               catch(Exception ex)
               {
                    myTrans.Rollback();
                    conn.Close();
                Response.Redirect("message.aspx?message=Erro closeOrderExec: " + Server.UrlEncode(ex.Message.ToString()), False);
               }

               finally
               {
                    if (conn.State == ConnectionState.Open)
                         conn.Close();
               }

          }

Hope this helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.