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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:42:38+00:00 2026-05-20T00:42:38+00:00

I am making multiple calls to ObjectContext.ExecuteStoreCommand with different commands and different parameters, although

  • 0

I am making multiple calls to ObjectContext.ExecuteStoreCommand with different commands and different parameters, although I use the same parameter list (object) for a several of the commands. I am getting the following exception:

System.ArgumentException: The SqlParameter is already contained by another SqlParameterCollection.

Is there a way to clear parameters between calls as I would do with straight up ADO.NET?

Updated with a code sample:

    string sqlDeleteWebUserGreen = "delete WebUserGreen where WebUserId = @WebUserId";
    string sqlDeleteWebUserBlue = "delete WebUserBlue where WebUserId = @WebUserId";

    var argsDeleteWebUserXref = new DbParameter[] {
        new SqlParameter { ParameterName = "WebUserId", Value = user.WebUserId }

    rowsAffectedDeleteWebUserXref += base.context.ExecuteStoreCommand(sqlDeleteWebUserGreen, argsDeleteWebUserXref);
    rowsAffectedDeleteWebUserXref += base.context.ExecuteStoreCommand(sqlDeleteWebUserBlue, argsDeleteWebUserXref);

UPDATE

Basically I am unable to find any better way of doing this, so I ended up accepting the answer below. The only difference is that I simply put the creation of the parameter into a separate method, so my calls look like base.context.ExecuteStoreCommand(sqlDeleteWebUserBlue, MethodThatWillGiveMeTheParameterArray());

  • 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-20T00:42:38+00:00Added an answer on May 20, 2026 at 12:42 am

    The problem is that you are using the same parameter twice.

    try this

    var argsDeleteWebUserXref1 = new DbParameter[] {         new SqlParameter { ParameterName = "WebUserId", Value = user.WebUserId }  
    
    var argsDeleteWebUserXref2 = new DbParameter[] {         new SqlParameter { ParameterName = "WebUserId", Value = user.WebUserId }  
    
    rowsAffectedDeleteWebUserXref += base.context.ExecuteStoreCommand(sqlDeleteWebUserGreen, argsDeleteWebUserXref1);      
    rowsAffectedDeleteWebUserXref += base.context.ExecuteStoreCommand(sqlDeleteWebUserBlue, argsDeleteWebUserXref2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a WinForms app with a ListView set to detail so that several
I have multiple views which make the same NSURLRequest/NSURLConnection request . Ideally, in order
Does anybody have any tips for utilizing multiple languages at the same time? I
I need to make multiple asynchronous service calls in the application:didFinishLaunchingWithOptions: method from my
We've got an application using spring for making calls to DB2 stored procedures. The
So I have multiple copies of the same database. Some of the tables are
I have a page that makes the same JSONP request multiple times in a
Making echo of a question around the web: Is the syntax for svn:ignore patterns
When making changes using SubmitChanges() , LINQ sometimes dies with a ChangeConflictException exception with
After making some changes in my models (eg. new field in a model and

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.