1 Replies - 3087 Views - Last Post: 15 November 2012 - 11:05 PM Rate Topic: -----

#1 suburbancowboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-November 12

Calling a tableadapter that holds multiple rows

Posted 15 November 2012 - 01:13 PM

I am having a problem pulling data into this foreach statement. the project builds like this with no errors however my calculation shows up as 0. there is data in that table but i seem to be missing something.

how can i use the tripsTableAdapter in the foreach statement? i am a newbie to this as well.
lines 8, 9, 12 seem to be where im missing something.

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

            var @settlementCurrentID = settlementCurrent.setID;

            this.tripsTableAdapter.FillByTripSetID(this.myLeaseDataSet.Trips, @settlementCurrentID);
            MyLeaseDataSet.TripsDataTable settlementTrips;
            settlementTrips = myLeaseDataSet.Trips;

            var totalLoadedMiles = 0;
            foreach (DataRow row in this.myLeaseDataSet.Trips.Rows)

                totalLoadedMiles += int.Parse(row["tripLoadedMiles"].ToString());
            labelWelcomeSetTotalMiles.Text = totalLoadedMiles.ToString();           

Is This A Good Question/Topic? 0
  • +

Replies To: Calling a tableadapter that holds multiple rows

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 5186
  • View blog
  • Posts: 13,914
  • Joined: 18-April 07

Re: Calling a tableadapter that holds multiple rows

Posted 15 November 2012 - 11:05 PM

Well first of all, have you tried putting a break point on the foreach and stepping through it to see what "row" get set to and if "tripLoadedMiles" even has a legit value? If it doesn't, then you can break on line 8 and see if the tripsTableAdapter is holding the right values.

This is one of those problems where a simple debug session could tell you lots about what is going on.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1