상세 컨텐츠

본문 제목

저장 프로시저 schema 검색

C#

by 탑~! 2009. 2. 20. 09:54

본문


class Program
{

static void Main(string[] args)
{
string connectionString = GetConnectionString();
using (SqlConnection connection = new SqlConnection(connectionString))
{
// Connect to the database then retrieve the schema information.
connection.Open();
DataTable table = connection.GetSchema("Procedures");
// Display the contents of the table.
DisplayData(table);
Console.WriteLine("Press any key to continue.");
Console.ReadKey();
}
}

private static string GetConnectionString()
{
// To avoid storing the connection string in your code,
// you can retrieve it from a configuration file.
return "Data Source=<servername>;Database=<database>;Integrated Security=SSPI;";
}

private static void DisplayData(System.Data.DataTable table)
{
  foreach (System.Data.DataRow row in table.Rows)
  {
    foreach (System.Data.DataColumn col in table.Columns)
    {
      Console.WriteLine("{0} = {1}", col.ColumnName, row[col]);
    }
    Console.WriteLine("============================");
  }
}

'C#' 카테고리의 다른 글

DotNetZip revs to v1.6 – now with Unicode support  (0) 2009.02.20
.Net Zip Library  (0) 2009.02.20
이벤트 동시 등록하는 방법  (0) 2008.06.18
ADO.NET DB연결 문자열  (0) 2008.06.18
Bulk Insert into SQL from C# App  (0) 2008.06.18

관련글 더보기