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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:57:06+00:00 2026-06-13T22:57:06+00:00

I have a tableadapter ( SettlementCurrentTableAdapter ) with a relation. parent table is (

  • 0

I have a tableadapter (SettlementCurrentTableAdapter) with a relation. parent table is (SettlementCurrent) child table is (Trips).

I need to SUM each row (tripLoadedMiles) in (Trips) and display the total in a label (labelWelcomeSetTotalMiles).

I would like to do this in code and not sql as i use this tableadapter to display other labels.

Can someone help me figure this out. i am new to C# and i use Visual C#.

        this.settlementCurrentTableAdapter.Fill(this.myLeaseDataSet.SettlementCurrent);
        MyLeaseDataSet.SettlementCurrentRow settlementCurrent;
        settlementCurrent = myLeaseDataSet.SettlementCurrent.Last();

        var settlementCurrentID = settlementCurrent.setID;

        this.tripsTableAdapter.FillByTripSetID(this.myLeaseDataSet.Trips, settlementCurrentID);
        MyLeaseDataSet.TripsDataTable settlementTrips;
        settlementTrips = myLeaseDataSet.Trips;
        foreach (DataRow row in myLeaseDataSet.Trips.Rows) 
        {

            NOT SURE ON THE CODE HERE

        }
  • 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-13T22:57:07+00:00Added an answer on June 13, 2026 at 10:57 pm

    Your first step is to extract the data you want out of your data adapter. Since I don’t have a table model in your question, it is best to look at the table adapter overview on MSDN, and click on the related links and articles to figure out the basic usage of this object. If you were to post your table structure, I could theoretically give you some code for it, but I’m reluctant to do that – you will have to work with this object a lot of it’s how you’re talking to your database, so it’s imperative you learn how it functions.

    Your goal in this learning is to figure out how to get all the miles figures out of your table adapter. You usually do this by going over one row at a time, and picking out the values you want to add them to a more C# idiomatic data structure, such as a a List/IEnumerable, or an Array.

    After you have the data you need in one of these structures, you can get the sum of everything by using LINQ. Depending on how much you pulled out, it can be as simple as one call (if this is something like an Array of ints):

    var totalMiles = tripLoadedMiles.Sum();
    

    Or as elaborate as you might need (if this is a List of a custom object that has both SettlementCurrentId and Miles, both stored as ints):

    var totalMiles = tripLoadedMiles.Select(x => x.SettlementCurrentId == someRandomRequiredSettlement).Sum(y => y.Miles);
    

    In the way you’re using things, this is how you’re looking at totaling it in this situation.

        var total = 0;
        foreach (DataRow row in myLeaseDataSet.Trips.Rows) 
        {
    
            total += int.Parse(row["tripTotalMiles"].ToString());
        }
        // Use the total
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have few tables in the database with parent table say P is having
I have DataSet and TableAdapter for the table in that DataSet. The problem is
I have a CheckedComboBoxEdit that's bound to a TableAdapter that populates it with a
have 2 questions : A computer with 32-bit address uses 2-level page table (9
I have a TableAdapter filling a DataSet , and for some reason every select
I have a Strongly typed Dataset TableAdapter in C#, how do I get a
I have added a dataset and connected with my table (Add New Item >>
I have a view from my database being represented as a TableAdapter, but I
I have a typed dataset, and where I call TableAdapter.Update(DataRow) , the SQL executed
Situation: In my database I have a table in which records may reference other

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.