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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:43:29+00:00 2026-05-17T18:43:29+00:00

I am putting information from a folder into a datatable. I’m putting the info

  • 0

I am putting information from a folder into a datatable. I’m putting the info into the datatable using the following code line:

dtUpgradeFileInfo.Rows.Add(nums[0],nums[1],nums[2],test1);

It appears to be working but I’m not as familiar with datatables in C# as I am in VB. How would i search the datatable where the first column has a certain value and the third column has the highest value in case there are multiple rows with the same value in the first column. I am also unsure of how to retrieve the info once I’ve found the row I need. The type for each column is int,int,int,string respectively.

  • 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-05-17T18:43:29+00:00Added an answer on May 17, 2026 at 6:43 pm

    If by VB you mean VB.NET and not something like VB6, then the code to work with DataTables (as opposed to legacy VB recordsets) will be the same in C#. Rather, the methods you would employ, obviously the syntax will be differently because it’s C#. There’s semi-colons and brackets where you might except parentheses. But they’re using the same objects, calling the same methods.

    Anyway, you could do this (C# 3.0+)

    DataRow matchingRow = (from DataRow row in dtUpgradeFileInfo.Rows
                           where (int)row["Column1"] == yourValue
                           orderby (int)row["Column3"] descending
                           select row).FirstOrDefault();
    
    if (matchingRow != null)
    {
        // get to work
    }
    

    And for a non-LINQ answer (any version of C#)

    string filter = "Column1 = " + yourValue.ToString();
    string sortOrder = "Column3 desc";
    
    dtUpgradeFileInfo.DefaultView.RowFilter = filter;
    dtUpgradeFileInfo.DefaultView.Sort = sortOrder;
    DataRow myRow = null;
    DataTable filteredTable = dtUpgradeFileInfo.DefaultView.ToTable();
    if (filteredTable.Rows.Count > 0)
        myRow = filteredTable.Rows[0];
    
    if (myRow != null)
    {
        // get to work
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to launch a Java app from a C++ app using the following
I am getting a list of file names using the following code: //Set up
From Australian voting problem: A bot will keep putting information and it can reach
I've been putting a lot of thought into procedural generation of content for a
I'm interested in putting together my first online game using Flash as the client
I've been following the tutorial from msdn and it just doesn't work. First problem
I am wondering how to ensure that an employee cannot access information from another
I'm doing multiple levels of parsing of web pages where I use information from
I like putting shortcuts of the form g - google.lnk in my start menu
We are putting up a company blog at companyname.com/blog but for now the blog

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.