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 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

Ask A Question

Stats

  • Questions 493k
  • Answers 493k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Best bet is just to iterate through the Map and… May 16, 2026 at 10:39 am
  • Editorial Team
    Editorial Team added an answer HeaderedItemsControl doesn't have a default style, so it's just using… May 16, 2026 at 10:39 am
  • Editorial Team
    Editorial Team added an answer Visual studio can't fix that. You can do it with… May 16, 2026 at 10:39 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a T-SQL stored procedure with the signature CREATE PROCEDURE MyProc @recordCount INT
Greetings, I have to following problem. I have a WCF Service which runs under
I have a SqlCommand which inserts a datetime into column using a SqlParameter. At
My insert stored procedure: ALTER procedure proj_ins_all ( @proj_number INT, @usr_id INT, @download DATETIME,
SQL injection that actually runs a SQL command is one thing. But injecting data
i have a function called ViewComments() which retrieve contents from database using SQL commands
I have an application that I'm developing in Visual Studio 2010 that utilizes a
I have a function GetAlertData() that returns a Datatable. I invoke it as: var
I am trying to create an SSIS package that queries data from a table,
A partner of ours is making a call to a web service that includes

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.