Net-informations.com
SiteMap  | About    

Range of records from database

In ADO.NET, DataTable objects are used to represent the tables in a DataSet. The DataSet is designed to be used in a disconnected mode.

vb.net

  Dim ds As New DataSet

C#

  DataSet ds = new DataSet();

In some situations we need to retrieve data only specific range of rows. In this situations we can fill the Dataset from DataAdapter only that specific range of rows. The following piece of code shows how to fill specific range of rows from DataAdapter to Dataset.

vb.net

  DataAdapter.Fill(Dataset, 5, 3, "tablename")

C#

  DataAdapter.Fill(Dataset, 5, 3, "tablename");

The above code will fill the Dataset starting from 5th row and 3 rows.

5 is the starting row no

3 is no of rows we want to fill.

The following ASP.NET program select data from authors table and display row no 5 to 3 rows.

Default.aspx

  

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
	<title>Untitled Page</title>
</head>
<body>
	<form id="form1" runat="server">
	<div>
	<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
		<br />
		<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>
	<br />
	<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
	</div>
	</form>
</body>
</html>


Click the following links to see full source code

C# Source Code
VB.NET Source Code
default.aspx.cs
default.aspx.vb





net-informations.com (C) 2016    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.