Home > DeveloperSection > Articles > DataReader

DataReader


ADO.Net ADO.Net 
Ratings:
1 Comment(s)
 3680  View(s)
Rate this:

DATAREADER

We can use DataReader in ADO.Net to retrieve a read-only, forward only stream of data from the database. Results are returned as the query executes Using the Data Reader can increase application performance both by retrieving data as soon as it is available, rather than waiting for the entire results of the query to be returned, and (by default) storing only one row at a time in memory, reducing system overhead. We cannot edit data in DataReader. After creating an instance of the Command object, you create a DataReader by calling Command.ExecuteReader () to retrieve rows from a data source.

The following example shows DataReader in c#.

 

//these lines are for creating a new connection by passing server name,uid,password and name of the database as here mind.

 

SqlConnection con = new SqlConnection("server=uttam-pc1\\sqlexpress; uid=sa; password=sa; database=mind");

//open connection      

con.Open();

string strQuery=”SELECT * FROM tblEmployee”;

SqlCommand cmd = new SqlCommand(strQuery,con);

 

//created datareader object

 SqlDataReader dr = cmd.ExecuteReader();  

 dr.read();

 txtID.Text=dr[0].tostring();

 con.close();//closing the connection


help about sql data reader button control

By Abdul Jabbar on   4 years ago

next i want to add a button which is display next record

Please help me about that issue


Don't want to miss updates? Please click the below button!

Follow MindStick