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...

If a dataset contains 100 rows, how to fetch rows between 10
and 20 only ?

Answer Posted / abhishek_gp3

Use Overloaded Fill() function of SqlDataAdapter Class of System.Data.SqlClient namespace.

Fill(1,2);
1- Dataset object
2- Table name

Fill(1,2,3,4);
1- Dataset Object
2- Starting Rec.
3- End Rec.
4- Table Name
--
Sample prog:
------
using System;
using System.Windows;
using System.Data;
using System.Data.SqlDataAdapter;

Class FetchRec
{
SqlConnection Con;
SqlDataAdapter Adap;
Dataset ds;

Public FetchRec()
{
Con = new SqlConnection("initial catalog=master;integrated security=yes");
Con.Open();

Adap= new SqlDataAdapter("Select ID, Name from Employee where ID > 110");

ds= new Dataset();
}//constructor end

try{
ds = Adap.Fill(ds, 10, 20, "Employee");

int rcount=ds.Tables["Employee"].Rows.Count;

for(int i=0; i < rcount ; i++)
{
Console.Writeline(ds.Tables["Employee"].Rows[i][0] + ds.Tables["Employee"].Rows[i][1]);
}

con.close();
} //try end
catch(SqlException exp)
{
MessageBox.Show(exp.Message);
}

}//class end

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the key features of ado.net?

1127


What is the difference between dataset and datatable?

938


What is the difference between the clone() and copy() methods of the dataset class?

1016


What is a sqldataadapter?

949


What is serialization and de-serialization in .net? How can we serialize the dataset object?

908


How to generate a single aggregate?

941


Which keyword is used to accept variable number of parameters?

1068


Difference between sqlcommand and sqlcommandbuilder?

1055


What is the default provider in ado.net?

911


What is the use of SqlCommand object?

1174


What is ado.net in mvc?

874


What is namespace in ado.net?

946


What is ole access?

886


What are the major challenges in accessing data from a database?

963


Which is better entity framework or ado.net?

973