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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:49:26+00:00 2026-05-11T12:49:26+00:00

I am not really sure if this is possible or not. I am currently

  • 0

I am not really sure if this is possible or not.

I am currently working on a college project and I have a function that uses stored procedures. I would like to know if it is possible to take the same SqlCommand instance and apply updated parameters to call into the stored procedure again within the same function.

Lets say i have something like this in my code:

myConStr = ConfigurationManager.ConnectionStrings['MyConnString'].ConnectionString; myConn = new SqlConnection(myConStr); myCommand = new System.Data.SqlClient.SqlCommand('team5UserCurrentBooks3', myConn);  myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue('@book_id', bookID); myCommand.Parameters.AddWithValue('@user_id', userID);  try {     myConn.Open();     myCommand.ExecuteNonQuery(); 

Is it possible to update MyCommand‘s parameters and call the stored procedure again?

  • 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. 2026-05-11T12:49:27+00:00Added an answer on May 11, 2026 at 12:49 pm

    Yes. You’ll want to make sure that you call myCommand.Parameters.Clear between each call in order to dump the parameters, but there’s nothing stopping you from reusing the object. (I don’t use C# often, so this may have an error or two in the text)

    myConStr = ConfigurationManager.ConnectionStrings['MyConnString'].ConnectionString; myConn = new SqlConnection(myConStr); myConn.Open();  myCommand = new System.Data.SqlClient.SqlCommand('team5UserCurrentBooks3', myConn);  myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue('@book_id', bookID); myCommand.Parameters.AddWithValue('@user_id', userID); myCommand.ExecuteNonQuery();  myCommand.Parameters.Clear(); myCommand.CommandText= 'NewStoredProcedureName'; myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue('@foo_id', fooId); myCommand.Parameters.AddWithValue('@bar_id', barId); mycommand.ExecuteNonQuery();  myCommand.Parameters.Clear(); myCommand.CommandText = ' SELECT * FROM table1 WHERE ID = @TID;' myCommand.CommandType = CommandType.Text; myCommand.Parameters.AddWithValue('@tid', tId); SqlReader rdr; rdr = myCommand.ExecuteReader(); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, not really sure if this is possible but thought I'd ask anyway :)
I know this is possible but I'm not really sure where to start. Has
I am not sure how to really word this, but I have a game
I have this project i'm working on and id like to add a really
I am not really sure what this method does, or better I am not
Not really sure how to phrase this other than by example.. Given... DATABASES =
I'm not really sure how to word this exactly, so hopefully someone can make
I'm not really sure how to get started on this and I sure could
Sorry, I'm not really sure of the right way to ask this one so
I feel like there's a simple solution to this, but I'm not really sure

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.