参考using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication30
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
private void Form1_Load(object sender, EventArgs e)
{
conn.ConnectionString = "Provider=SQLOLEDB;server=.;uid=sa;pwd=sqlgis;database=master";
conn.Open();
DataTable tbTables= conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null);
this.comboBox1.DataSource = tbTables;
this.comboBox1.DisplayMember = "Table_Name";
this.comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged);
} void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string strTableName = this.comboBox1.Text;
DataTable tbColumns = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Columns, new object[] { null, null, strTableName, null });
this.listBox1.DataSource = tbColumns;
this.listBox1.DisplayMember = "Column_Name";
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication30
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
private void Form1_Load(object sender, EventArgs e)
{
conn.ConnectionString = "Provider=SQLOLEDB;server=.;uid=sa;pwd=sqlgis;database=master";
conn.Open();
DataTable tbTables= conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null);
this.comboBox1.DataSource = tbTables;
this.comboBox1.DisplayMember = "Table_Name";
this.comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged);
} void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string strTableName = this.comboBox1.Text;
DataTable tbColumns = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Columns, new object[] { null, null, strTableName, null });
this.listBox1.DataSource = tbColumns;
this.listBox1.DisplayMember = "Column_Name";
}
}
}
DataAdapter.FillSchema (DataSet, SchemaType)