SqlCommand.CommandType : SqlCommand « System.Data.SqlClient « C# / C Sharp by API






SqlCommand.CommandType

 
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.SqlCommand.BeginExecuteReader
2.SqlCommand.CommandText
3.SqlCommand.EndExecuteReader
4.SqlCommand.ExecuteNonQuery()
5.SqlCommand.ExecuteScalar()
6.SqlCommand.ExecuteXmlReader()
7.SqlCommand.Parameters
8.SqlCommand.Parameters.Add