How to read data from database using SqlDataReader in C#

Import the System.Data.SqlClient first.

using System.Data.SqlClient;

SqlDataReader provides a way of reading a forward-only stream of rows from a SQL Server database.

SqlDataReader are used when the need is simply to display the records, not update them. You cannot update using SqlDataReader.

The code below is pretty self explanatory(read the comments), in case of queries please feel free to write in using the comment box below.

using System;
using System.Data.SqlClient;

class Program
{
static void Main()
{
// assign connectionString
string connectionString = "your connection string to go here";

using (SqlConnection con = new SqlConnection(connectionString))
{
// Open the SqlConnection.
con.Open();

string command = "SELECT * FROM YASSER_Table"; 

using (SqlCommand command = new SqlCommand(command, con))
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
Console.WriteLine("{0} {1}",
reader.GetInt32(0), reader.GetString(1));
}
}

}// end of using (SqlConnection)

}
}

References : 

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.aspx

http://www.dotnetperls.com/sqldatareader