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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:45:28+00:00 2026-05-17T06:45:28+00:00

The overloaded method SqlParameterCollection.Add(String, Object) has been marked as deprecated since version 3.5 SP1

  • 0

The overloaded method SqlParameterCollection.Add(String, Object) has been marked as deprecated since version 3.5 SP1 of the .NET Framework. You should use the AddWithValue() method that was introduced with version 2.0.

Is there a good reason why the Add(String, Object) has been replaced with a AddWithValue()? I’m fine with the change, but I am curious about why the change was made.

  • 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-17T06:45:28+00:00Added an answer on May 17, 2026 at 6:45 am

    I would think that it’s because of the possibility for misuse described in the MSDN docs you referenced:

    Use caution when you are using this
    overload of the
    SqlParameterCollection.Add method to
    specify integer parameter values.
    Because this overload takes a value of
    type Object, you must convert the
    integral value to an Object type when
    the value is zero, as the following C#
    example demonstrates.

    parameters.Add("@pname", Convert.ToInt32(0));
    

    If you do not perform this conversion,
    the compiler assumes that you are
    trying to call the
    SqlParameterCollection.Add (string,
    SqlDbType) overload.

    In fact the docs you referenced for the new API say as much:

    The overload of Add that takes a
    string and an object was deprecated
    because of possible ambiguity with the
    SqlParameterCollection.Add overload
    that takes a String and a SqlDbType
    enumeration value where passing an
    integer with the string could be
    interpreted as being either the
    parameter value or the corresponding
    SqlDbType value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to Invoke an overloaded method using reflection in .NET (2.0).
I have a method that I'm writing that is calling another overloaded method inside
I am using a class Foo that provides these methods: String overloadedMethod(Object) String overloadedMethod(Goo)
The code below generates a warning CS3006 Overloaded method MyNamespace.Sample.MyMethod(int[])' differing only in ref
Possible Duplicate: C#: Passing null to overloaded method - which method is called? Here
How can I find a generic overloaded method? For example, Queryable 's public static
I have a class with an overloaded method: MyClass.DoThis(Action<Foo> action); MyClass.DoThis(Action<Bar> action); I want
I have a class with both a overloaded constructor and a overloaded method. If
What Linq expression would I use to select the 1rst overloaded method that accepts
In this particular code sample I want to reference the second overloaded method (int

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.