Get data from IDataReader : IDataReader : ADO.Net C# Examples


C# Examples » ADO.Net » IDataReader »

 

Get data from IDataReader









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

class  MainClass
{
        public  static  void  Main()
        {
                using  (SqlConnection  con  =  new  SqlConnection())
                {
                        con.ConnectionString  =  @"Data  Source  =  .\sqlexpress;"  +
                                "Database  =  Northwind;  Integrated  Security=SSPI";
                        con.Open();

                        //  Create  and  configure  a  new  command.
                        IDbCommand  com  =  con.CreateCommand();
                        com.CommandType  =  CommandType.StoredProcedure;
                        com.CommandText  =  "MyStoredProcedure";
        
                        //  Execute  the  command  and  process  the  results
                        using  (IDataReader  reader  =  com.ExecuteReader())
                        {
                                while  (reader.Read())
                                {
                                        Console.WriteLine("    {0}  ",  reader["FirstName"]);
                                }
                        }
                }
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo ADO.Net
» IDataReader