CSharp.Net-Informations.com
   Home      .Net Framework      VB.NET      C#                                                                      About


  Find Tables in a Dataset - OLEDB

The DataSet contains DataTableCollection and their DataRelationCollection . The DataTableCollection contains zero or more DataTable objects. The data inside Table is in the form of Rows and Columns . The OleDbDataAdapter Object allows us to populate DataTables in a DataSet. The DataTable class is a member of the System.Data namespace within the .NET Framework class library.

ADO.NET enables you to create DataTable objects and add them to an existing DataSet. In some situations we have to find the number of tables resides in a Dataset Object . The following C# source code shows how to find the tables inside in a Dataset.

         C# Source Code Download           Print Source Code
         Find Tables in a Dataset - OLEDB - Download
        
C# Tutorial

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;
            int i = 0;

            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();

                for (i = 0; i <= ds.Tables.Count - 1; i++)
                {
                    MessageBox.Show (ds.Tables[i].TableName);

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not open connection ! ");
            }
        }
    }
}



CSharp Dataset Related Contents
*     What is C# ADO.NET Dataset
*     C# Datset with Sql Server Data Provider
*     C# Datset with OLEDB Data Provider
*     Find Tables in a Dataset - Sql Server
*     How to Dataset rows count - Sql Server
*     How to Dataset rows count - OLEDB
*     How to find Column Definition SqlServer
*     How to find Column Definition OLEDB
*     How to Dyanamic Dataset in C#
*     C# Dataset with multiple tables - Sql Server
*     C# Dataset with multiple tables - OLEDB
*     C# Dataset table relations
*     C# Dataset merge tables - Sql Server
*     C# Dataset merge tables - OLEDB


   Home      VB.NET      C#
CSharp Related Topics
*     An overview of Microsoft CSharp
*     C# Language Tutorial
*     C# Statements Tutorial
*     C# Collection Tutorial
*     C# String Tutorial
*     C# File Operations Tutorial
*     C# Excel Tutorial
*     C# Crystal Reports Tutorial
*     CSharp Communication Tutorial
*     C# Ado.Net Tutorial and Source Code
*     C# ADO.NET data Providers Tutorial
*     C# Dataset Tutorial
*     C# DataAdapater Tutorial
*     Csharp DataView Tutorial
*     Csharp Remoting Tutorial
*     C# XML Tutorial
*     C# DataGridView Tutorial
   Home      VB.NET      C#
More Source Code :   
Mail to :  feedback@net-informations.com
  |  Home   |  VB.NET   |  C#   |  SiteMap   |  Terms of Use   |  About   |
net-informations.com (C) 2010
All Rights Reserved. All other trademarks are property of their respective owners.