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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:26:50+00:00 2026-05-31T08:26:50+00:00

I have a stored procedure that goes like this: ALTER PROCEDURE [dbo].[AuthenticateUser] @AzUserName varchar(20),

  • 0

I have a stored procedure that goes like this:

ALTER PROCEDURE [dbo].[AuthenticateUser]    
    @AzUserName varchar(20),
    @Hash varchar(32),
    @UserId bigint output,
    @Authorized bit output
    ...

and runs just fine fine in Management Studio.
Here’s my C# code:

SqlConnection scon = new SqlConnection(connectionString);
SqlCommand authCmd = new SqlCommand("AuthenticateUser", scon);
authCmd.CommandType = System.Data.CommandType.StoredProcedure;

SqlParameter userNameParam = authCmd.Parameters.Add("@AzUserName", System.Data.SqlDbType.VarChar, 20);
                        userNameParam.Value = username;
string hashed = Md5Hash.ComputeHash(username);

SqlParameter hashedParam = authCmd.Parameters.Add("@Hash", System.Data.SqlDbType.VarChar, 32);
hashedParam.Value = hashed;

SqlParameter userIdParam = authCmd.Parameters.Add("@UserId", System.Data.SqlDbType.Int);
userIdParam.Direction = System.Data.ParameterDirection.ReturnValue;

SqlParameter authorizedParam = authCmd.Parameters.Add("@Authorized", System.Data.SqlDbType.Bit);
authorizedParam.Direction = System.Data.ParameterDirection.ReturnValue;

scon.Open();
authCmd.ExecuteNonQuery();
scon.Close();

When I run it I am getting the following error:

{"Procedure or function 'AuthenticateUser' expects parameter '@UserId', which was not supplied."}   System.Exception {System.Data.SqlClient.SqlException}

When I replace ParameterDirection.ReturnValue with ParameterDirection.Output I am not getting the error but never get the value of the procedure.

UPDATE:
Thank you All for your help. The error was more trivial than you would have thought and I described in the question. I have been changing back and forth ReturnValue to Output for quite a while today with no result. Then I had to post my question on SO just to realize that I am taking the hash value of … username..Going outdoor to get some oxygen now.

  • 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-31T08:26:52+00:00Added an answer on May 31, 2026 at 8:26 am

    You will have to use ParameterDirection.Output on every parameter, that has been marked with output in T-SQL. You can access the values, after the call to

    authCmd.ExecuteNonQuery();
    

    by getting the values of the parametes like this:

    authCmd.Parametes["@UserId"].Value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure that goes something like this (pseudo code) storedprocedure param1,
I have a stored procedure call that goes like this: using (OracleConnection con =
I have a stored procedure that has the parameter: @desk VARCHAR(50) I want to
I have this stored procedure that I want to use for my SAP crystal
I have a stored procedure that has this line: SET @SQL = 'SELECT path,title,tags
I have a stored procedure that logs some data, how can I call this
I have this stored procedure, that reads data from xml and make some inserts
I created a stored procedure for my .NET project and it goes like this,
Well I have this MySQL stored procedure that I wrote and if I run
I have a SQL Server 2008 stored procedure (pseudocode below) that goes as follows:

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.