new SqlParameter : SqlParameter « System.Data.SqlClient « C# / C Sharp by API






new SqlParameter

  
using System;
using System.Data;
using System.Data.SqlClient;

class MainClass
{
  static void Main(string[] args)
  {
    SqlConnection cn = new SqlConnection("Data Source=(local); Initial  Catalog = MyDatabase; User ID=sa;Password=");
    SqlCommand cmd = new SqlCommand("MyStoredProcedure", cn);
    cmd.CommandType = CommandType.StoredProcedure;
    SqlParameter param = new SqlParameter("@ReturnValue", SqlDbType.Int);
    cmd.Parameters.Add(param);
    cmd.Parameters.Add("MyFirstParameter", SqlDbType.Int);
    cmd.Parameters.Add("MySecondParameter", SqlDbType.Int).Direction =
    ParameterDirection.Output;
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    
  }
}

   
    
  








Related examples in the same category

1.SqlParameter.ParameterName
2.SqlParameter.SourceVersion
3.SqlParameter.Value