C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ADO.NET »

Get all the table names from mdb file


Posted Date: 22 Oct 2009    Resource Type: Code Snippets    Category: ADO.NET
Author: Shunmuganathan MMember Level: Diamond    
Rating: 1 out of 5Points: 12



We can get all the table names from the .mdb file using the
following code.

Name spaces used

using System;
using System.Data;
using System.Data.OleDb;


Code part

public class DatabaseInfo {
public static void Main () {
String MyConnectionsting = "Provider=Microsoft.JET.OLEDB.4.0;data source=.\\Portel.mdb";

OleDbConnection MyOleDbConnection = new OleDbConnection(MyConnectionsting);
MyOleDbConnection.Open();
Console.WriteLine("Database Connection opened");
DataTable MyDataTable = MyOleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,new object[]{null,null,null,"TABLE"});

Console.WriteLine("Following are the details of the tables in Porter.mdb");
foreach(DataRow MyDataRow in MyDataTable.Rows)
{
Console.Write(" {0}", MyDataRow[2]);
}
MyOleDbConnection.Close();
}
}



Code Explanation

1. Create the instance of the OleDbConnection using connectionsting
2. open the connection
3. Create the Datatable by getting all the table details
4. By fetching the eath datarow of the data table we can get the table details of the database

By
Nathan



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Get all the table name from mdb file  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Restricting the Webpart Manager Displaymodes based on user roles
Previous Resource: Get the table details
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use