SQL StoredProcedure : SqlCommand : ADO.Net C# Examples


C# Examples » ADO.Net » SqlCommand »

 

SQL StoredProcedure









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

class  Program  {
        static  void  Main(string[]  args)  {
                SqlConnection  thisConnection  =  new  SqlConnection(
                        @"Server=(local)\sqlexpress;Integrated  Security=True;"  +
                        "Database=northwind");

                thisConnection.Open();

                SqlCommand  thisCommand  =  thisConnection.CreateCommand();
                thisCommand.CommandType  =  CommandType.StoredProcedure;
                thisCommand.CommandText  =  "Ten  Most  Expensive  Products";

                SqlDataReader  thisReader  =  thisCommand.ExecuteReader();
                while  (thisReader.Read())  {
                        Console.WriteLine("\t{0}\t{1}",
                        thisReader["TenMostExpensiveProducts"],  thisReader["UnitPrice"]);
                }
                thisReader.Close();

                thisConnection.Close();
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo ADO.Net
» SqlCommand