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 9162345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:11:20+00:00 2026-06-17T14:11:20+00:00

So I have a snippet of the code here that works except for one

  • 0

So I have a snippet of the code here that works except for one line which is the InsertAt() part. I would like to know if it is possible to copy the last row and insert it as the first. Think of the idea as this. It probably can be done in the SQL alone behind it but this application is designed to work for both a very old database and oracle so until the system migrates entirely it has to be done like this, unfortunately.

Prior

  • Shipment Location 1
  • Shipment Location 2
  • Shipment Location 2

After

  • Start Location
  • Shipment Location 1
  • Shipment Location 2
  • Shipment Location 3
  • Destination Location

The code snippet:

// Create a DataTable with a list of shipments.    
DataTable dt = c.Query(c.qShipments(Row.Cells[0].Value.ToString()));
// Check if there is at least one shipment
if (dt.Rows.Count >= 1)
{
    // Add the destination of the shipments
    dt.Rows.Add(0, 0, 9999, textBox_CC.Text, textBox_PC.Text, textBox_SL.Text);
    // Add the starting location (which is the same as the destination. It has to be at the top of the DataTable
    dt.Rows.InsertAt(dt.Rows[dt.Rows.Count - 1], 0); // The code

    // Finally calculate and return the object to populate the datagridview with.
    dataGridView_CalculatedRoutes.Rows.Add(x.getRoute(dt));
}

tldr;

Issue: Code returns Row belongs to another table.

Question: How to get the last row to be the first aswell?

Edit question: How to get the last row to be both the first and the last row. (Identical rows)

  • 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-17T14:11:21+00:00Added an answer on June 17, 2026 at 2:11 pm

    You could create a new DataTable and import the rows in the order that you want:

    // Create a DataTable with a list of shipments.    
    DataTable dt = c.Query(c.qShipments(Row.Cells[0].Value.ToString()));
    // Check if there is at least one shipment
    if (dt.Rows.Count >= 1)
    {
        DataTable customDt = new DataTable();
    
        // Add the starting location (which is the same as the destination. It has to be at 
        customDt.Rows.Add(0, 0, 9999, textBox_CC.Text, textBox_PC.Text, textBox_SL.Text);
    
        foreach(DataRow row in dt.Rows)
        {
            customDt.ImportRow(row);
        }
        // Add the destination of the shipments
        customDt.ImportRow(customDt.Rows[0]);
    
        // Finally calculate and return the object to populate the datagridview with.
        dataGridView_CalculatedRoutes.Rows.Add(x.getRoute(dt));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small code snippet for deleting element in linked list. Here is
I have a class with two constructors (C#). Here is the code snippet: public
I have below snippet of code in which TestClass is extending jPanel which is
I have a snippet of code that creates an array clusterUniqueMarkers that stores all
In an Activity, I have some snippet of code that fires off a Message:
I have those code snippet that checks the fans table and gets everyone who
I have a page with multiple forms that I would like to submit and
I'm am having a heck of a time finding a code snippet that works
I have a snippet of code that applies a highlighting effect to list items
We have some solution that we built against a MOSS farm one of which

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.