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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:04:15+00:00 2026-05-11T08:04:15+00:00

I am writing this in C# using .NET 3.5. I have a System.Data.DataSet object

  • 0

I am writing this in C# using .NET 3.5. I have a System.Data.DataSet object with a single DataTable that uses the following schema:

Id      :  uint AddressA:  string AddressB:  string Bytes   :  uint 

When I run my application, let’s say the DataTable gets filled with the following:

1   192.168.0.1   192.168.0.10   300 2   192.168.0.1   192.168.0.20   400 3   192.168.0.1   192.168.0.30   300 4   10.152.0.13   167.10.2.187    80 

I’d like to be able to query this DataTable where AddressA is unique and the Bytes column is summed together (I’m not sure I’m saying that correctly). In essence, I’d like to get the following result:

1   192.168.0.1   1000 2   10.152.0.13     80 

I ultimately want this result in a DataTable that can be bound to a DataGrid, and I need to update/regenerate this result every 5 seconds or so.

How do I do this? DataTable.Select() method? If so, what does the query look like? Is there an alternate/better way to achieve my goal?

EDIT: I do not have a database. I’m simply using an in-memory DataSet to store the data, so a pure SQL solution won’t work here. I’m trying to figure out how to do it within the DataSet itself.

  • 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. 2026-05-11T08:04:16+00:00Added an answer on May 11, 2026 at 8:04 am

    For readability (and because I love it) I would try to use LINQ:

    var aggregatedAddresses = from DataRow row in dt.Rows group row by row['AddressA'] into g select new {     Address = g.Key,     Byte = g.Sum(row => (uint)row['Bytes']) };  int i = 1; foreach(var row in aggregatedAddresses) {     result.Rows.Add(i++, row.Address, row.Byte); } 

    If a performace issue is discovered with the LINQ solution I would go with a manual solution summing up the rows in a loop over the original table and inserting them into the result table.

    You can also bind the aggregatedAddresses directly to the grid instead of putting it into a DataTable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a searching function, and have thought up of this query using
I have an asynchronous socket listener class like this: using System; using System.Collections.Generic; using
I'm writing a project in c# asp.net mvc3, and I have a helper-class that
Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws a
I was just writing some quick code and noticed this complier error Using the
I'm writing a C parser using PLY, and recently ran into a problem. This
I'm writing this question from the standpoint of an ASP.NET application. However I realize
I am writing a piece of software in C# using .NET 2 which detects
I am considering using ADO.Net Data Services in a project for the purpose of
My application I have an application design that looks like this: web application layer

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.