How to Dataset rows count - OLEDB

The DataSet Object contains copy of the data we requested through the SQL statement. The DataSet consists of DataTableCollection and their DataRelationCollection . The DataTableCollection contains zero or more DataTable objects. A DataSet represents a complete set of data including the tables that contain, order, and constrain the data, as well as the relationships between the tables.

The data inside Table is in the form of Rows and Columns . The DataRow Class represents the actual data contained in a table. You use the DataRow and its properties and methods to retrieve, evaluate, and manipulate the data in a table. 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.

using System;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;

namespace WindowsApplication1
    public partial class Form1 : Form
        public Form1()

        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);
                oledbAdapter = new OleDbDataAdapter(sql, connection);
                oledbAdapter.Fill(ds, "OLEDB Temp Table");

                MessageBox.Show ("number of Row(s) - " + ds.Tables[0].Rows.Count);
            catch (Exception ex)
                MessageBox.Show("Can not open connection ! ");
} (C) 2021    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About