Get a database table properties

This program displays your table properties such as its column names, types, and column properties. I have used a database "mcTest.mdb" which has a table called 'Developer'. You can download this attached database and change the path of the database according to your location.
 
Explanation
 
I have used ADODataSetCommand, DataSet, DataTable, and DataColumn classes to do so. See my forthcoming tutorial on ADO.NET for more details of these classes.
  1. private void Form1_Load(object sender, System.EventArgs e) {  
  2.     string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\mcTest.MDB";  
  3.     string strSQL = "SELECT * FROM Developer";  
  4.     // create Objects of ADOConnection and ADOCommand  
  5.     OleDbConnection myConn = new OleDbConnection(strDSN);  
  6.     OleDbDataAdapter myCmd = new OleDbDataAdapter(strSQL, myConn);  
  7.     myConn.Open();  
  8.     DataSet dtSet = new DataSet();  
  9.     myCmd.Fill(dtSet, "Developer");  
  10.     DataTable dt = dtSet.Tables[0];  
  11.     listBox1.Items.Add("Field Name DataType Unique AutoIncrement AllowNull");  
  12.     listBox1.Items.Add("=================================");  
  13.     foreach(DataColumn dc in dt.Columns) {  
  14.         listBox1.Items.Add(dc.ColumnName + " , " + dc.DataType + " ," + dc.Unique + " ," + dc.AutoIncrement + " ," + dc.AllowDBNull);  
  15.     }  
How to Run?
  • Download source code and database zip files and unzip them.
  • Change the database path  in this string.  "Provider=Microsoft.JET.OLEDB.4.0;data source=C:\\Mahesh\\mcb.mdb");
  • Run the application