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

  • Home
  • SEARCH
  • 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 8794111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:12:30+00:00 2026-06-13T23:12:30+00:00

I have an SQL Server Stored Procedure . This procedure have an output parameter.

  • 0

I have an SQL Server Stored Procedure. This procedure have an output parameter.
On my C#.NET Appliaction, I execute this procedure via SqlHelper.ExecuteDataSet() and it returns a query result DataSet.
How can I get the output parameter from the stored procedure procedure while using SqlHelper.ExecuteDataSet().
Some article said that I need to use SqlHelper.ExecuteNonQuery() but I need the DataSet too.

This is my code:

        public DataSet GetDataPerTable(string spName, string a, string b, out int c)
        {
            try
            {
                c = 0;

                SqlParameter[] spParameter = new SqlParameter[3];

                spParameter[0] = new SqlParameter("@a", SqlDbType.Char, 4);
                spParameter[0].Direction = ParameterDirection.Input;
                spParameter[0].Value = a;

                spParameter[1] = new SqlParameter("@b", SqlDbType.Char, 1);
                spParameter[1].Direction = ParameterDirection.Input;
                spParameter[1].Value = b;

                spParameter[2] = new SqlParameter("@c", SqlDbType.Int);
                spParameter[2].Direction = ParameterDirection.ReturnValue;                
                c = Convert.ToInt32(spParameter[2].Value);

                return SqlHelper.ExecuteDataset(Configuration.MyConnectionString, CommandType.StoredProcedure, spName, spParameter);
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

My c variable always return 0. Any Idea? Thanks in advance 🙂

My Procedure is about like this:

CREATE PROCEDURE [dbo].SPR_MyProcedure (@a Char(4), @bChar(1), @c Int Output)  
SELECT * 
FROM MyTable
Set @c = 1
  • 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-13T23:12:31+00:00Added an answer on June 13, 2026 at 11:12 pm

    @c isn’t the a return value, it’s an output parameter

    Change

    spParameter[2].Direction = ParameterDirection.ReturnValue; 
    

    to

     spParameter[2].Direction = ParameterDirection.Output;
    

    Also, you need to set your c variable after the call to ExecuteDataset
    eg:

    DataSet dataset = SqlHelper.ExecuteDataset(Configuration.MyConnectionString, CommandType.StoredProcedure, spName, spParameter);
    c=(int)spParameter[2];
    return dataset;     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a SQL Server stored procedure that includes a DateTime parameter. This
I have repeatedly test this #blankety-blank# stored procedure on SQL Server, and it returns
Helo, My question is I have one Stored Procedure in SQL Server that returns
Possible Duplicate: SQL Server Full text Index SQL Server stored procedure parameter output I
I have a SQL Server stored procedure that is not returning any data when
I have a SQL server stored procedure which would accept date as input param
I have the following SQL Server stored procedure : BEGIN TRAN CREATE TABLE #TempTable
I have a stored procedure on SQL Server 2005. It is pulling from a
I have the following stored procedure in an SQL Server 2005 database (meant simply
I have a stored procedure for sending an email from SQL Server. The email

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.