using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ParameterProb
{
    class Program
    {
        static void Main(string[] args)
        {

            using (SqlConnection conn = new SqlConnection("server=.;database=test2;integrated security=sspi"))
            using (SqlCommand cmd = new SqlCommand("select * from Candidat where ca_Code = @ca_Code", conn))
            {
                // parameter is nvarchar(11)
                cmd.Parameters.AddWithValue("@ca_Code", "00000009701"); 

                //cmd.Parameters.Add("@ca_Code", SqlDbType.VarChar);
                //cmd.Parameters[0].Value = "00000009701";
                conn.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
            }
            
            /*
            using (SqlConnection conn = new SqlConnection("server=.;database=pubs;integrated security=sspi"))
            using (SqlCommand cmd = new SqlCommand("timeproc", conn))
            {
                conn.Open();

                // parameter is int
                // parameter is varchar(27)
                //cmd.Parameters.AddWithValue("@price", "$2.99");

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@d", SqlDbType.DateTime2);
                cmd.Parameters[0].Value = "2009-04-20 10:29:32.2505872";
                SqlDataReader rdr = cmd.ExecuteReader();
            }
            */

        }
    }
}
