using System;
using System.Data.SqlClient;
public class GetTableList
{
public static void Main()
{
string connectionString = "Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI";
string SQL = "SELECT TABLE_TYPE, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(SQL, con);
SqlDataReader r;
con.Open();
r = cmd.ExecuteReader();
while (r.Read()){
Console.WriteLine(r[0] + ": " + r[1]);
}
con.Close();
}
}
|