获取数据库架构信息
可以使用Connection或DataReader对象的GetSchemaTable方法获取数据库的架构信息。
1
using System;
2
using System.Drawing;
3
using System.Collections;
4
using System.ComponentModel;
5
using System.Windows.Forms;
6
using System.Data;
7
using System.Data.OleDb;
8
9
namespace 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
}
using System;2
using System.Drawing;3
using System.Collections;4
using System.ComponentModel;5
using System.Windows.Forms;6
using System.Data;7
using System.Data.OleDb;8

9
namespace GetDataBaseSchema10
{11
/// <summary>12
/// frmGetDBSchema 的摘要说明。13
/// </summary>14
public class frmGetDBSchema : System.Windows.Forms.Form15
{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
}


浙公网安备 33010602011771号