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   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
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
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
If a dataset contains 100 rows, how to fetch rows between 10
and 20 only ?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: If a dataset contains 100 rows, how to fetch rows between 10 and 20 only ?
Answer
# 1
Dataset consists of DataTable collection which consists of 
DataRows. Create Dataset object, then create DataRow object

Dim objRow as New DataRow

objRow(9) to objTow(19) woud give the rows between 10 and 
20, as first row is stored with index 0.
 
Is This Answer Correct ?    0 Yes 0 No
Vijay
 
  Re: If a dataset contains 100 rows, how to fetch rows between 10 and 20 only ?
Answer
# 2
Dataset consists of DataTable collection which consists of 
DataRows. Create Dataset object, then create DataRow object

Dim objRow as New DataRow

objRow(9) to objTow(19) woud give the rows between 10 and 
20, as first row is stored with index 0.
 
Is This Answer Correct ?    0 Yes 0 No
Satyambabu
 
 
 
  Re: If a dataset contains 100 rows, how to fetch rows between 10 and 20 only ?
Answer
# 3
Dataset consists of DataTable collection which consists of 
DataRows. Create Dataset object, then create DataRow object

Dim objRow as New DataRow

objRow(9) to objTow(19) woud give the rows between 10 and 
20, as first row is stored with index
 
Is This Answer Correct ?    0 Yes 0 No
Ramesh
 
  Re: If a dataset contains 100 rows, how to fetch rows between 10 and 20 only ?
Answer
# 4
We can use DataTable.Select method to fetch rows. see the 
following example:
In this 
customerTable.Select( strExpr, strSort, 
DataViewRowState.Added ) fetches the records which is 
greater then 5.

Private Sub GetRowsByFilter()
    
    Dim customerTable As DataTable
    customerTable = new DataTable( "Customers" )

    ' Add columns
    customerTable.Columns.Add( "id", GetType(Integer) )
    customerTable.Columns.Add( "name", GetType(String) )

    ' Set PrimaryKey
    customerTable.Columns("id").Unique = true
    customerTable.PrimaryKey = new DataColumn() { 
customerTable.Columns("id") }

    ' add ten rows
    Dim id As Integer
    For id = 1 To 10
        customerTable.Rows.Add( _
            new object() { id, string.Format("customer{0}", 
id) } )
    Next id
    customerTable.AcceptChanges()

    ' add another ten rows
    For id = 11 To 20
        customerTable.Rows.Add( _
            new object() { id, string.Format("customer{0}", 
id) } )
    Next id

    Dim strExpr As String
    Dim strSort As String
    
    strExpr = "id > 5"
    ' Sort descending by CompanyName column.
    strSort = "name DESC"
    ' Use the Select method to find all rows matching the 
filter.
    Dim foundRows As DataRow() = _
        customerTable.Select( strExpr, strSort, 
DataViewRowState.Added )
    
    PrintRows( foundRows, "filtered rows")

    foundRows = customerTable.Select()
    PrintRows( foundRows, "all rows")
End Sub

Private Sub PrintRows( rows() As DataRow, label As String)
    Console.WriteLine( "\n{0}", label )
    If rows.Length <= 0 Then
        Console.WriteLine( "no rows found" )
        Exit Sub
    End If
    Dim r As DataRow
    Dim c As DataColumn
    For Each r In rows
        For Each c In r.Table.Columns
            Console.Write( "\t {0}", r(c) )
        Next c
        Console.WriteLine()
    Next r
End Sub
 
Is This Answer Correct ?    0 Yes 0 No
Bhuvana
 
  Re: If a dataset contains 100 rows, how to fetch rows between 10 and 20 only ?
Answer
# 5
objRow(9) to objTow(19)

mentioned above would return the column index and would not 
return the loop.

Corrrect me if I am wrong
 
Is This Answer Correct ?    0 Yes 0 No
Anu
 
  Re: If a dataset contains 100 rows, how to fetch rows between 10 and 20 only ?
Answer
# 6
for(int 
RowsCount=1;RowsCount<dataset.rows.count;RowsCount++)
{
    if(RowsCount>10 && RowsCount<20)
     {
       //if you GirdView or DataGrid 
        Gridview1.DataSource=dataset;
        GridView1.DataBind()

     }
}
 
Is This Answer Correct ?    1 Yes 0 No
Suresh Jayaraman
 
  Re: If a dataset contains 100 rows, how to fetch rows between 10 and 20 only ?
Answer
# 7
DataRow[] dr = new DataRow[10];
for(int i = 10 to 19)
   dr[i] = DataSet1.Tables[<TableIndex>].Rows[i];

DataRow array dr contains Records between 10 and 20.
 
Is This Answer Correct ?    0 Yes 0 No
Vaidyanathan R.
 
  Re: If a dataset contains 100 rows, how to fetch rows between 10 and 20 only ?
Answer
# 8
DataSet ds = new DataSet();
        ds.Load(cmd.ExecuteReader(),
LoadOption.OverwriteChanges, "sample");

        DataRow[] dr = ds.Tables[0].Select("id>1 and id<10");

        for (int i = 0; i < dr.Length; i++)
        {
            Response.Write(dr[i][0].ToString()+"<br>");
             
            
        }
 
Is This Answer Correct ?    0 Yes 0 No
Muthu Kumar
 
  Re: If a dataset contains 100 rows, how to fetch rows between 10 and 20 only ?
Answer
# 9
We have the option of the fetching the starting record and
the maximum record options.

_dataadapter.Fill(_dset,"Test",11,10);

It will retrieve the record from 11 to next 10 records.
 
Is This Answer Correct ?    0 Yes 0 No
Tiger Kumar
 
  Re: If a dataset contains 100 rows, how to fetch rows between 10 and 20 only ?
Answer
# 10
_adapter.Fill(ds,11,10).
or By iterate record from 11 to 20.
 
Is This Answer Correct ?    0 Yes 0 No
Avanish Singh
 

 
 
 
Other ADO.NET Interview Questions
 
  Question Asked @ Answers
 
How would u connect to database using .NET? TCS2
What providers do you use to connect to oracle database ? Digital-GlobalSoft4
What is the provider and namespaces being used to access oracle database? Microsoft4
Sequence to connect and retrieve data from database useig dataset ? MMTS3
what is a dataview?why is it used for? Choice-Solutions3
Can you edit data in the Repeater control?  7
what is sql Injection? Microsoft4
How to sort the data in Datatable NetProphet2
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 three Ado objects? Microsoft5
Which method do you invoke on the DataAdapter control to load your generated dataset with data? Veegyapan-Impacts3
Being fresher How would i answer to the question that what is your salary exception?  3
What are the different namespaces used in the project to connect the database?  2
what is execute scalar? Protech6
What is ODP.NET? Microsoft1
What is the difference between oledbreader and datasetwhile connecting?  1
i have two textboxes one for user name and another for password . i have a table name compare(which contains name,passwod etc.,)my doubt is how compare username textbox with name column and how compare password textbox with passwod column. i want the code Wipro3
Where does ADO.NET and XML web services come in the architecture ? TCS1
How to get the new oledb connection of oracle in database programming?  1
what is clustered index?why is it created? Microsoft3
 
For more ADO.NET Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

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