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
What is the difference between sqldatareader and sqldataadapter?
What is read only and forward only in ado.net?
Which is better ole db or odbc?
What is serialization and de-serialization in .net? How can we serialize the dataset object?
How does ado.net work?
What are typed and untyped dataset?
Define Execute Reader?
What does ole stand for in excel?
What are the connected and disconnected modes in ado.net?
How do you update database through dataset?
Describe datareader object of ado.net with example.
What is the difference between a datareader and a dataset?
What is oledb driver?
What we do with the object of ado.net dataset after using it?
Define executenonquery?