How to Dataset rows count - OLEDB

The DataSet object holds a copy of the data retrieved through a SQL statement or query. It is comprised of a DataTableCollection, which stores zero or more DataTable objects. Each DataTable represents a structured table of data that contains rows and columns. The tables within the DataSet define the organization, ordering, and constraints of the data.

Number of rows in a table

A DataSet represents a complete set of data, including the tables, their order, and the relationships between them. It provides a comprehensive and self-contained representation of the data retrieved from the data source. The following C# source code shows how to find the number of rows in a table that resides in the Dataset from an OLEDB Data Source.

Full Source C#
using System; using System.Data; using System.Data.OleDb; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string connetionString = null; OleDbConnection connection ; OleDbDataAdapter oledbAdapter ; DataSet ds = new DataSet(); string sql = null; connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your mdb filename;"; sql = "Your SQL Statement Here"; connection = new OleDbConnection(connetionString); try { connection.Open(); oledbAdapter = new OleDbDataAdapter(sql, connection); oledbAdapter.Fill(ds, "OLEDB Temp Table"); oledbAdapter.Dispose(); connection.Close(); MessageBox.Show ("number of Row(s) - " + ds.Tables[0].Rows.Count); } catch (Exception ex) { MessageBox.Show("Can not open connection ! "); } } } }

Within each DataTable, the actual data is stored in the form of rows and columns. The DataRow class represents an individual row of data within a table. It offers various properties and methods that allow you to retrieve, evaluate, and manipulate the data stored within a specific table. You can access the DataRow and its properties to perform operations such as retrieving specific values, modifying data, or evaluating conditions.


Using the DataSet, DataTableCollection, and DataRow classes, developers can effectively work with and manipulate data in a tabular format. The DataSet provides a versatile and flexible way to handle complete sets of data, while the DataRow class enables fine-grained access and manipulation of individual rows within a table.