Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can a DataReader be used as a DataSource for a GridView.
If it is so how will you handle paging.

Answer Posted / dinesh sharma

_cmd.Connection = CON; //_cmd is sqlCommand and
CON is Connection
_cmd.CommandText = "select
Book_Code,ISBN,Title_Of_book from Book_Master";
SqlDataReader dr = _cmd.ExecuteReader();
dts.Columns.Add("Book_Code");
dts.Columns.Add("ISBN");
dts.Columns.Add("Title_Of_book"); DataRow drs;
while (dr.Read())
{
drs = dts.NewRow();
drs[0] = dr[0].ToString();
drs[1] = dr[1].ToString();
drs[2] = dr[2].ToString();
dts.Rows.Add(drs);

Application.DoEvents();




}
dataGridView2.DataSource = dts;


dr.Close();
_cmd.Dispose();

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is ole used for?

889


Define partial class?

901


How can we check that some changes have been made to dataset since it was loaded?

917


What is concurrency? How will you avoid concurrency when dealing with dataset? (One user deleted one row after that another user through his dataset was trying to update same row. What will happen? How will you avoid the problem?)

943


What is linq and entity framework?

937


What provider ado.net use by default? Explain the role of data provider in ado.net?

919


What is oledb connection?

931


What does ado stand for?

866


What is ado object model?

892


What are the different ado.net namespaces?

1015


What is the use of SqlCommandBuilder?

1146


What is the difference between sqlcommand and sqldataadapter?

947


What are all the different authentication techniques used to connect to MS SQL Server?

1008


How to aggregating data across related tables?

975


What is the difference between SqlCommand and SqlCommandBuilder?

998