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

  • Home
  • SEARCH
  • 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 8392395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:30:30+00:00 2026-06-09T19:30:30+00:00

When I Sort menu: => keep Event:Sorting from Mouse => Menu: Home(1) News(2) About(3)

  • 0

When I Sort menu: => keep Event:Sorting from Mouse =>

Menu:

   Home(1)   News(2)    About(3)    =>    News(2)     Home(1)     About(3)

Event will save position to two table at the same time.

I know using Trigger can solve this problem. But structure of two table is different. So, I cannot use Trigger for this.

Now, I want inserting/updating will looks like two table.

table1:

          Order
           2
           1
           3

table2:

           Order: 213

How can I update/insert for two above tables at the same time.

Tks a lot

This is Event of Sorting for Update to two tables but it seems update to table1

            //-------Update for table: Items---------//
            command.Connection = connection;
            command.CommandText = "UpdateItemsOrder";
            command.CommandType = CommandType.StoredProcedure;
            SqlParameter paramUserName = new SqlParameter("@ItemOrder", SqlDbType.VarChar, 255);
            paramUserName.Value = itemOrder;
            command.Parameters.Add(paramUserName);
            //----Update for table: NewOrders(get data from column ItemOrder)--//
            string username = "aloha";
            DemoDataContext dc = new DemoDataContext();
            var strJoin= (from m in dc.Items
                             select m.ItemOrder);
            var result = string.Join("", strJoin.Select(x => x.Value).ToArray());
            var reUpdateOrder = dc.NewOrders.Single(a => a.UserOrder.Equals(username));
            reUpdateOrder.NewItemOrder = result;
            dc.SubmitChanges();
            connection.Open();
            return (command.ExecuteNonQuery() > 0);

It inserts only to table:Items, not get data from Items at that time to update for table:NewOrders.
Connection always open for Sorting.

Please help me.

  • 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-09T19:30:31+00:00Added an answer on June 9, 2026 at 7:30 pm

    This is just a guess, but it looks as though NewOrders may not have a primary key established..? You may be able to select orders by username, but without a primary key, LINQ-to-SQL won’t know how to find update the record upon calling dc.SubmitChanges();

    Also, is there any particular reason you are leaving the SqlConnection open for sorting? This can lead to threading issues in some cases and is usually best left to the connection pool to handle.

    SubmitChanges() will open it’s own connection, so there’s no need to keep the SqlConnection open for it. You should handle each update separately:

    //-------Update for table: Items---------//
    using(SqlConnection conn = new SqlConnection(...))
    {
        SqlCommand command = new SqlCommand();
        command.Connection = conn;
        command.CommandText = "UpdateItemsOrder";
        command.CommandType = CommandType.StoredProcedure;
    
        SqlParameter paramUserName = new SqlParameter("@ItemOrder", SqlDbType.VarChar, 255);
        paramUserName.Value = itemOrder;
        command.Parameters.Add(paramUserName);
    
        conn.Open();
        command.ExecuteNonQuery();
    }
    
    //----Update for table: NewOrders(get data from column ItemOrder)--//
    string username = "aloha";
    DemoDataContext dc = new DemoDataContext();
    var strJoin = (from m in dc.Items
                   select m.ItemOrder);
    
    var result = string.Join("", strJoin.Select(x => x.Value).ToArray());
    var reUpdateOrder = dc.NewOrders.Single(a => a.UserOrder.Equals(username));
    reUpdateOrder.NewItemOrder = result;
    dc.SubmitChanges();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to sort the start menu alphabetically using C#. I've read about deleting
I have a select menu that looks like this: <select id ="cal-category-select"> <option value="/event-sort/list/2009/9/sports/">Sports
I have a PHP-based sorting method with a drop-down menu to sort rows. It
I am looking for some sort of jQuery click menu that will open up
I want to create an Activity which shows a sort of menu a user
I've sort of paginated a large menu — user sees 12 items at a
So I've made a menu sort of thing, affixed to the bottom of the
Menu has_many :dishes. I want to sort the dishes by Dish.number. Currently in my
I'm developing some sort of air mouse application for iPhone platform. This applications connects
I want to make a menu sort of similar to Yelps front page .

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.