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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:48:32+00:00 2026-05-15T00:48:32+00:00

I have 2 samples that effectively do the same thing — Sample 1: command.Parameters.Add(ParamFoo,

  • 0

I have 2 samples that effectively do the same thing —
Sample 1:

command.Parameters.Add(ParamFoo, SqlDbType.Int)
command.Parameters(ParamFoo).Value = fooVal

Sample 2:

command.Parameters.AddWithValue(ParamBar, barVal)

Which sample would be recommended? I know that the second sample is making some conversions. Wouldn’t it be best to not require conversions and go with the first sample?

  • 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-15T00:48:33+00:00Added an answer on May 15, 2026 at 12:48 am

    As you posted your code, is completely irrelevant. Both variants will perform identically, there will be no way you can measure the cost of in-client converts against the huge background of the database call.

    However, there is a very very big known problem when barVal is of type String. The SqlClient will add the parameters as type NVARCHAR and when used in SQL expressions in comparing with a VARCHAR column, the SQL type precedence rules will require the column to be converted to NVARCHAR instead of the variable to be converted to VARCHAR, and this changes index seeks into table scans and has disastrous performance consequences.

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

Sidebar

Related Questions

If you have audio encoded at 44100Hz that means you have 44100 samples per
I have a system that takes Samples. I have multiple client threads in the
I have a measure device that creates samples in the following format: V GL020(1)=20110117161703
I have a C# game program that i'm developing. it uses sound samples and
I have a wave file, i have a function that retrieves 2 samples per
I have a sample page that uses 2 PHP files and a MySql database,
Visual Studio 2005 C++ Windows XP Pro I have a sample application that I
I have the following code sample that im trying to wrap my head around
Below I have written a sample program that I have written to learn about
Does MS have a sample enterprise application that demonstrates the use of different Enterprise

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.