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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:22:22+00:00 2026-05-15T22:22:22+00:00

Importing a spreadsheet I have filled a DataTable object with that data and returns

  • 0

Importing a spreadsheet I have filled a DataTable object with that data and returns expected results.

Attempting to put this into a format I can easily query to search for problem records I have done the following

public void Something(DataTable dt)
{
     var data = from row in dt.AsEnumerable()
                select row["Order"].ToString();
}

Works as expected giving me a list of orders. However I cannot add other fields to this EnumerableRowCollection. Attempting to add other fields as follows gives me an error

public void Something(DataTable dt)
{
     // row["Version"] throws an error on me
     var data = from row in dt.AsEnumerable()
                select row["Order"].ToString(), row["Version"].ToString();
}

Error: “A local variable named ‘row’ cannot be declared in this scope because it would give a different meaning to ‘row’ which is already used in a ‘child’ scope to donate something else”

I’m thinking I need to alias the column name but I’m having no luck. What am I missing 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-05-15T22:22:23+00:00Added an answer on May 15, 2026 at 10:22 pm

    It sounds like you’re writing a bad select statement. Try the following:

    public void Something(DataTable dt)
    {
        var data = from row in dt.AsEnumerable()
                   select new { 
                                Order = row["Order"].ToString(), 
                                Something = row["Something"].ToString(),
                                Customer = row["Customer"].ToString(),
                                Address = row["Address"].ToString()
                              };
    }
    

    That will create a new collection of Anonymously Typed objects that you can iterate over and use as needed. Keep in mind, though, that you want be able to return data from the function. If you need that functionality, you need to create a concrete type to use (in place of anonymous types).

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

Sidebar

Related Questions

Background I have a spreadsheet of data that I'm importing into SQL Server 2005.
I have data from an Excel spreadsheet that I want to import into a
I have a spreadsheet that I am importing that contains some test data for
I have a question regarding importing( Via the import/export wizard) an excel spreadsheet into
While importing data from a flat file, I noticed that some of lines have
I am importing data from MySQL to PowerPivot. I have all of the relevant
I have a spreadsheet that is currently formatted improperly for a mysql import. The
I have an excel spreadsheet that has dates in the first column, the rest
I have a google spreadsheet with multiple columns that have variable row counts in
For whatever reason, I have a lot of clients that have existing data that's

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.