我想选择一个数据库,然后再combox中列出这个数据库的所有表的名称,请问怎么实现?
msdn上有这些代码,能否给解释一下:
using System;
using System.Data;
using System.Data.OleDb;
class Class1
{
static void Main()
{
string x = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=AdventureWorks;"
+ "Integrated Security=SSPI";
GetSchemaTable(x);
Console.ReadLine();
}
static DataTable GetSchemaTable(string connectionString)
{
using (OleDbConnection connection = new
OleDbConnection(connectionString))
{
connection.Open();
DataTable schemaTable = connection.GetOleDbSchemaTable(
OleDbSchemaGuid.Tables,
new object[] { null, null, null, "TABLE" });
return schemaTable;
}