获取数据库架构信息

可以使用Connection或DataReader对象的GetSchemaTable方法获取数据库的架构信息。

  1using System;
  2using System.Drawing;
  3using System.Collections;
  4using System.ComponentModel;
  5using System.Windows.Forms;
  6using System.Data;
  7using System.Data.OleDb;
  8
  9namespace GetDataBaseSchema
 10{
 11    /// <summary>
 12    /// frmGetDBSchema 的摘要说明。
 13    /// </summary>

 14    public class frmGetDBSchema : System.Windows.Forms.Form
 15    {
 16        public frmGetDBSchema()
 17        {
 18            //
 19            // Windows 窗体设计器支持所必需的
 20            //
 21            InitializeComponent();
 22
 23            //
 24            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
 25            //
 26        }

 27
 28        /// <summary>
 29        /// 清理所有正在使用的资源。
 30        /// </summary>

 31        protected override void Dispose( bool disposing )
 32        {
 33            if( disposing )
 34            {
 35                if (components != null
 36                {
 37                    components.Dispose();
 38                }

 39            }

 40            base.Dispose( disposing );
 41        }

 42
 43        Windows 窗体设计器生成的代码
142
143        /// <summary>
144        /// 应用程序的主入口点。
145        /// </summary>

146        [STAThread]
147        static void Main() 
148        {
149            Application.Run(new frmGetDBSchema());
150        }

151
152        变量区
159
160        功能区
222
223        private void btnChooseDBFile_Click(object sender, System.EventArgs e)
224        {
225            ChooseDBFile();
226        }

227
228        private void cboTables_SelectedIndexChanged(object sender, System.EventArgs e)
229        {
230            OnChooseTable();
231        }
        
232    }

233}
posted on 2006-07-24 17:13  莫相会  阅读(430)  评论(0编辑  收藏  举报