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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:12:00+00:00 2026-05-24T21:12:00+00:00

I have a problem with a DataRow that I’m really struggling with. The datarow

  • 0

I have a problem with a DataRow that I’m really struggling with.

The datarow is read in from an Excel spreadsheet using an OleDbConnection.

If I try to select data from the DataRow using the column name, it returns DBNull even though there is data there.

But it’s not quite that simple.

datarow.Table.Columns[5].ColumnName returns “my column”.
datarow["my column"] returns DBNull.
datarow[5] returns 500.
datarow[datarow.Table.Columns[5].ColumnName] returns DBNull. (just to make sure its not a typo!)

I could just select things from the datarow using the column number, but I dislike doing that since if the column ordering changes, the software will break.

  • 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-24T21:12:02+00:00Added an answer on May 24, 2026 at 9:12 pm

    Which version of .NET are you using? Since .NET 3.5, there’s an assembly System.Data.DataSetExtensions, which contains various useful extensions for dataTables, dataRows and the like.

    You can try using

    row.Field<type>("fieldName");
    

    if that doesn’t work, you can do this:

    DataTable table = new DataTable();
    var myColumn = table.Columns.Cast<DataColumn>().SingleOrDefault(col => col.ColumnName == "myColumnName");
    if (myColumn != null)
    {
        // just some roww
        var tableRow = table.AsEnumerable().First();
        var myData = tableRow.Field<string>(myColumn);
        // or if above does not work
        myData = tableRow.Field<string>(table.Columns.IndexOf(myColumn));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem creating new instance of excel 2007 using VBA (from Access 2002).
My problem is really simple. I have a .bak file that contains one or
I have come accross a strange problem that can be illustrated using the 2
I've been struggling with a problem that I have for days now and I
i have a problem with my code. foreach (DataRow dr in dt_pattern.Rows) { part
I frequently have problems dealing with DataRows returned from SqlDataAdapters . When I try
I have problem thinking this trough with PHP & Mysql . I have read
I have problem in some JavaScript that I am writing where the Switch statement
I have problem when I try insert some data to Informix TEXT column via
I have a problem that has been bugging me all day. In my code

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.