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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:25:11+00:00 2026-06-14T05:25:11+00:00

I know that the usually recommended way to fill a DataSet instance from a

  • 0

I know that the usually recommended way to fill a DataSet instance from a stored procedure is to use SqlDataAdapter.Fill(DataSet). Every answer I’ve been able to find says to use it the way it comes out of the box. I’ll grant that normally, it works great.

However, it breaks down when you need to do processing of the data between the stored procedure output and the DataSet input. Specifically, when using a custom CLR type in the output, it breaks with InvalidOperationException: DataReader.GetFieldType(n) returned null. where n is the column index of the column (in one of the tables; there seems to be no obvious way of telling which table the column index references) which uses the CLR type in its output. This is understandable, since the reader has no idea what kind of data is in the column in question.

I can break out the deserialization logic of the CLR type and use it in both places, but I don’t seem to have time to call any such deserialization method before Fill() breaks down.

I know about SqlCommand.ExecuteReader(), but can only seem to get a single table out of that one.

The CLR type in question is designed to replace one of the core system fields (which is currently stored as free-form text) with something a little more stringent. The question of going through the database and adding a method call to every single returned instance of such a field has been discussed as a possibility but would definitely be a non-trivial amount of work. So it was thought that the conversion could be done in the DAL instead (only requiring that such columns can be identified programmatically, which is doable), making storage transparent to the client and client use of the data still transparent to the database.

Thus: How do I get access to all the tables in the stored procedure output, without using SqlDataAdapter.Fill()? Alternatively, how do I hook into the execution of SqlDataAdapter.Fill() to do manual processing between execution of the SP and the populating the DataSet?

  • 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-14T05:25:12+00:00Added an answer on June 14, 2026 at 5:25 am

    You can select multiple tables with a DataReader. You can use reader.NextResult to check if there are more resultsets and to advance the data reader to it:

    using (var con = new SqlConnection(Properties.Settings.Default.ConnectionString))
    {
        using (var cmd = new SqlCommand("StoredProcedureName", con))
        {
            cmd.CommandType = CommandType.StoredProcedure;
            int rowCount = 0;
            con.Open();
            using (IDataReader rdr = cmd.ExecuteReader())
            {
                while (rdr.Read())
                {
                    Console.WriteLine("Object 1 in Row {0}: '{1}'", ++rowCount, rdr[0]);
                }
                if (rdr.NextResult())
                {
                    rowCount = 0;
                    while (rdr.Read())
                    {
                        Console.WriteLine("Object 1 in Row {0}: '{1}'", ++rowCount, rdr[0]);
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this is usually not the way to use AngularJS but I
I know that the likes of the DotNetZip or SharpZipLib libraries are usually recommended
So I know that Error inflating class usually is because of a missing or
I know that when I use range([start], stop[, step]) or slice([start], stop[, step]) ,
I've read all the posts and know that IndexOutOfRange usually happens because a column
I know that regex usually should not be used for parsing html content. In
I know that it is usually considered bad practice to mix CSS with HTML
I know that questions of that kind are usually not desirable, but I still
I know that a software engineer usually isn't screaming, hey all I'm not getting
I know that usually you want to strip these out, but I need the

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.