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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:42:31+00:00 2026-05-16T05:42:31+00:00

I have a SqlCommand which runs a stored procedure that contains two integer output

  • 0

I have a SqlCommand which runs a stored procedure that contains two integer output parameters. Right before the SqlCommand runs I can see that the output parameters are set to the correct values, however when the command actually executes, it uses a NULL for parameter1 and 0 for parameter2 (verified using SQL Profiler) regardless of what I set the parameters to.

A simplified version of the code is this:

foreach (KeyValuePair<string, object> parameter in outputParameters)
{
    SqlParameter param = new SqlParameter(parameter.Key, parameter.Value);
    param.Direction = ParameterDirection.Output;
    command.Parameters.Add(param);
}

command.ExecuteNonQuery();

I’m confused by two different things here:

1) Why isn’t it using the values in the parameters? I can place a breakpoint right before command.ExecuteNonQuery() and see that the command.Parameters list has the output parameters set correctly, however the SQL profiler trace has different parameters when the query gets executed.

2) Both parameters are integers and defined the exact same way – Why is one set to NULL while the other set to 0??

  • 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-16T05:42:32+00:00Added an answer on May 16, 2026 at 5:42 am

    They’re output parameters – i.e. the value is meant to come from the stored procedure… logically they don’t have values on input. If you want the values from the client to be used in the stored procedure, they should have a direction of InputOutput.

    EDIT: Responding to your comment – Output means just output. Input means just input. InputOutput means both ways. It sounds like you want both ways, so use InputOutput.

    As for why one is null and the other not… I don’t know, to be honest.

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

Sidebar

Related Questions

I have two tables: Accounts , which contains the information of accounts that a
I have created a stored procedure in SQL Server, which runs immediately from Management
I have a stored procedure which is written in c#: SqlConnection scn = new
I have a stored procedure which checks the username and the password from a
I have the following SQLCommand which should do an Update. The issue is, that
I have a stored procedure that goes like this: ALTER PROCEDURE [dbo].[AuthenticateUser] @AzUserName varchar(20),
I have stored procedure which update Customers and a datagridview to work with the
I have written a simple stored procedure for updating a record which isn't working
I have a stored procedure: CREATE PROCEDURE [dbo].[brbackup] @dataID [nvarchar](max), @backupdata [varbinary](max) OUTPUT WITH
I have a stored procedure that has a parameter called UserName and in 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.