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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:54:54+00:00 2026-06-13T14:54:54+00:00

We have run a conversion tool on an old project which came from VB6.

  • 0

We have run a conversion tool on an old project which came from VB6.

We’re substituting OLEDB with Ado.Net, and RecordSets with SqlDataReaders.

But the converted code always does a rs.Fields['FirstName'] reference, which I guess would be rs['FirstName'] with the database reader (where rs is now q SqlDataReader.

Instead of going through all the code, is there a way I could create an extension method on SqlDataReader, which would then make use of “Fields['FieldName']“?

This is my current attempt:

public static class SqlUtils
    {
        public static object Fields(this SqlDataReader dataReader, string fieldname)
        {
            return dataReader[fieldname];
        }
    }

However, this works with:

Console.WriteLine(reader.Fields("First").ToString());

I need to handle:

Console.WriteLine(reader.Fields["First"].ToString());

Note, [], not ().

  • 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-06-13T14:54:55+00:00Added an answer on June 13, 2026 at 2:54 pm

    Extension methods are actually just static methods. Since there is no ‘static indexer’ you cannot have an extension method that uses indexer syntax.

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

Sidebar

Related Questions

I have a complex database conversion console app that reads from an old database,
I have run through the MVC3 Razor tutorial on ASP.Net, and and have started
I am trying to run lame from a php script. I have tried these,
Possible Duplicate: Tool to convert python indentation from spaces to tabs? I have a
I have the following acceptance criteria for creating a pdf file from my asp.net
I have the following piece of inline SQL that I run from a C#
I am using notepad++ to do some date conversions but have run into a
I have run into a problem with Eclipse Indigo, attempting to start up my
I have run this Perl code: #!/usr/bin/perl print content-type: text/html \n\n; print Hello World.\n;
I have run this command with root: [root@localhost git-shell-commands]# ssh git@192.168.1.12 git@192.168.1.12's password: Last

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.