ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  ADO.NET
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
Can a DataReader be used as a DataSource for a GridView.
If it is so how will you handle paging.
 Question Submitted By :: KiranMadiraju
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Can a DataReader be used as a DataSource for a GridView. If it is so how will you handle paging.
Answer
# 1
_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 ?    2 Yes 1 No
Dinesh Sharma
 
  Re: Can a DataReader be used as a DataSource for a GridView. If it is so how will you handle paging.
Answer
# 2
yes u can use data reader to fill gridview with while
function. and paging depends upon the datagrid property. if
u use custom paging there in no possibility with data
reader. u will have to use data table to fill data grid and
data table should be filled through data reader.
 
Is This Answer Correct ?    5 Yes 0 No
Rahul Singhal
 
 
 
  Re: Can a DataReader be used as a DataSource for a GridView. If it is so how will you handle paging.
Answer
# 3
some changes made in the above code

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();
DataTable dataTable = new DataTable();
dataTable.Load(dr);
dr.Close();
_cmd.Dispose();

dataGridView2.DataSource = dataTable;
 
Is This Answer Correct ?    1 Yes 0 No
Karthikeyant
 

 
 
 
Other ADO.NET Interview Questions
 
  Question Asked @ Answers
 
what is connection pooling ? Vertex3
Explain different methods and Properties of DataReader which you have used in your project?  2
What provider ADO.net use by default? Accenture5
What is dataset and tell about its features. What are equivalent methods of previous, next etc. Of ADO in ADO.NET ? Digital-GlobalSoft1
What are the two fundamental objects in ADO.NET? Ksb3
If we want to connect to many databases in dataaccess layer such as MSAccess,Sql server,oracle means not to a particular database depends on condition we have to connect to appropriate database in this scenario if we without changing code Ho wdo you handle this situation? Honeywell4
What providers do you use to connect to oracle database ? Digital-GlobalSoft4
What are the steps in connecting to database ? Microsoft2
What we do with the object of ado.net dataset after using it?Can we dispose it or can we set it nothing?Is it must or not? SVI4
Being fresher How would i answer to the question that what is your salary exception?  3
types of Store procedure in Sqlserver2000?  4
Which method do you invoke on the DataAdapter control to load your generated dataset with data?  3
Can you edit data in the Repeater control?  8
What is datacolumn and how it is used?  2
How would u connect to database using .NET? TCS3
Difference between OLEDB Provider and SqlClient ?  2
What is a datatable? SBI8
How to sort the data in Datatable NetProphet2
can we have multiple datatables in a datareader ? Ness-Technologies14
What is ODP.NET? Microsoft2
 
For more ADO.NET Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com