Posted on 2007-10-03
Last Modified: 2008-01-09
SqlCommand.Parameters.Add() has 5 overloads.
Which one should typically be used, and why? Should you specify DbType? What is this for?
Question by:JRockFL
    LVL 22

    Accepted Solution

    I use this one:
    This way, the callers of the DB Access class I have can create a list of parameters appropriate to the current request. They pass the parameter list in with the SQL or SP name.

    SqlDbType tells and code that refers to the parameter how to interpret the content of the Value member.

    LVL 4

    Assisted Solution

    I use sqlparameter one.   I have a class that contains all the connections to the database. I send to the class a ArrayList of Sqlparameters. In the class member I loop though the ArrayList and then add each one to the ot the sqlcommand.

    ex.  ArrayList mysqlpara = new ArrayList();
    mysqlpara.add(new sqlclient.sqlparameter("@name",txtName.Text);

    The DbType is for it you are controling the data type to the database. I havint used it yet. I beleve you get a error on code side if you put the wrong type in, instead of the database reportiing it back.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now