It provides a forward-only, read-only, connected recordset.
It is most efficient to use when data need not to be updated, and requires forward only traverse. In other words, it is the fastest method to read data.
Mostly Used:
- Filling dropdownlistbox.
- Comparing username and password in database
Example:
SqlDataReader rdr = cmd.ExecuteReader();
//Reading data
while (rdr.Read())
{
//Display data
string contact = (string)rdr["ContactName"];
string company = (string)rdr["CompanyName"];
string city = (string)rdr["City"];
}
No comments:
Post a Comment