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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:42:56+00:00 2026-05-12T08:42:56+00:00

Can anyone tell me how I can control the output from an SQL stored

  • 0

Can anyone tell me how I can control the output from an SQL stored procedure that returns more than one set of output?

I am currently doing the following:

        DataTable allData = new DataTable();
        SqlConnection connection = new SqlConnection(mySource);

        SqlCommand cmd = new SqlCommand(procedureName, connection);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(paramName, SqlDbType.Int);
        cmd.Parameters[paramName].Value = paramValue;

        connection.Open();

        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
        adapter.Fill(allData);

        connection.Close();

Now this works fine if the procedure has only one output value, but how do I deal with the following:

My stored procedure broadly does the following:

It calls a number of other stored procedures in order to construct a dynamic SQL query (lets call this @query) and then calls EXECUTE(@query) which does a SELECT.

Using the code snippet above returns the result from the SELECT query, which is fine. But what I would also like it so have the string @query returned. I can specify it as an output type and let SQL fetch it, but how do I access it from c#? (Actually, more specifically, when I do this the code snipped above returns only the string @query and no longer returns the results of the SELECT)

Thanks

Karl

  • 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-12T08:42:57+00:00Added an answer on May 12, 2026 at 8:42 am

    You can do like this:

     DataSet allData = new DataSet ();
     ...
     ...
     ...
      adapter.Fill(allData);
    

    then each result of the select is in different dataTable

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

Sidebar

Related Questions

My question today is more theoretical than technical, but here goes. Can anyone tell
can anyone tell me that how can i use UIpagecontrol control of iphone by
Can anyone tell me how to call the n number of activities from different
Can anyone tell me what control or how do you create the pop-up effect
Can anyone tell me how to raise click event of button control (or for
Can anyone tell me how to prevent multiple cells from being selected in datagridview
Can anyone tell me why this code would not be working? $('body').on('test', function() {
can anyone tell me how to select data by date in MS.ACCESS database using
Can anyone tell me why the following code fails to submit the form into
Can anyone tell me how I can correctly pass my application context to my

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.