1. SqlConnection thisConnection = new SqlConnection ();
ThisConnection. Open (StrConn );
SqlCommand thisCommand = thisConnection. CreateCommand ();
// The command type is stored procedure
ThisCommand. CommandType = CommandType. StoredProcedure;
// Name of the stored procedure
ThisCommand. CommandText = "Ten Most Expensive Products ";
// Execute the Stored Procedure
SqlDataReader thisReader = thisCommand. ExecuteReader ();
// Display the result
While (thisReader. Read ())
{
Console. WriteLine ("\ t {0} \ t {1}", thisReader ["TenMostExpensiveProducts"], thisReader ["UnitPrice"]);
}
2.
MyCommand. CommandType = CommandType. StoredProcedure;
// Add input query parameters and assign values
MyCommand. Parameters. Add ("@ Name", SqlDbType. VarChar );
MyCommand. Parameters ["@ Name"]. Value = "";
// Add output parameters
MyCommand. Parameters. Add ("@ Rowcount", SqlDbType. Int );
MyCommand. Parameters ["@ Rowcount"]. Direction = ParameterDirection. Output;
MyCommand. ExecuteNonQuery ();
DataAdapter. SelectCommand = myCommand;
If (MyDataSet! = Null)
{
DataAdapter. Fill (MyDataSet, "table ");
}