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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:35:21+00:00 2026-06-14T06:35:21+00:00

I have stored proc as below: ALTER PROC pr_Update_Users_Nomination ( @UserID AS VARCHAR(100), @Nominated

  • 0

I have stored proc as below:

ALTER PROC pr_Update_Users_Nomination
(
      @UserID AS VARCHAR(100),  
      @Nominated AS BIT
)
AS

UPDATE User
SET isNominated = @Nominated
WHERE 
EMPID = @UserID;

I want to call this procedure from c# code: Below is the code I am trying:

void OpenConnection()
{
string Nominated = "False";
    //Connection String
        string sConnString = System.Configuration.ConfigurationManager.ConnectionStrings["ConString1"].ConnectionString;
        SqlConnection mySqlCon = new SqlConnection(sConnString);
        SqlCommand mySqlCom = mySqlCon.CreateCommand();

        //Call the stored proc and provide in parameters
        mySqlCom.CommandText = "EXECUTE pr_Update @UserID @Nominated";
        mySqlCom.Parameters.Add("@UserID", SqlDbType.VarChar, 20).Value = UserID;
        mySqlCom.Parameters.Add("@Nominated", SqlDbType.Bit).Value = Nominated;

        mySqlCon.Open();
        mySqlCom.ExecuteNonQuery();
        mySqlCon.Close();
}

I get an error saying

Incorrect Syntax near @Nominated
  • 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-14T06:35:22+00:00Added an answer on June 14, 2026 at 6:35 am

    first, when executing a procedure with parameter(s), separate the parameters with a comma

    EXECUTE pr_Update @UserID, @Nominated
    

    second, modify your code into this,

        string sConnString = System.Configuration.ConfigurationManager.ConnectionStrings["ConString1"].ConnectionString;
        using(SqlConnection mySqlCon = new SqlConnection(sConnString))
        {
            using(SqlCommand mySqlCom = new SqlCommand())
            {
                mySqlCom.Connection = mySqlCon;
                mySqlCom.CommandText = "pr_Update";
                mySqlCom.CommandType = CommandType.StoredProcedure;
                mySqlCom.Parameters.Add("@UserID", SqlDbType.VarChar, 20).Value = UserID;
                mySqlCom.Parameters.Add("@Nominated", SqlDbType.Bit).Value = Nominated;
                try
                {
                    mySqlCon.Open();
                    mySqlCom.ExecuteNonQuery();
                }
                catch(SqlException ex)
                {
                    // do something with the exception
                    // don't hide it
                }
    
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this stored Proc: ALTER Procedure [dbo].[GetWebinars] ( @GroupingCode varchar(max) = 'AVM', @ItemNumber
I have a stored Proc: USE [RMV1] GO ALTER PROCEDURE [dbo].[INS_Respond_Local] @phone varchar(15), @wphone
I have a stored proc with the basic layout below that returns a sys_refcursor
If I have this stored proc definition minus the body ALTER PROCEDURE sp_AlloctionReport(@where NVARCHAR(1000),
I have a stored proc were I want to insert a GUID (user id)
I have a stored proc that I need to execute 100 times (one for
Currently I have a stored proc, which takes a string @vari as varchar(30) if
I have a stored proc that should conditionally update a bunch of fields in
I have a Stored Proc query below which involves returning partial delimited search string.
I have two queries below. how do i put them in one stored proc.

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.