Code
private static DataTable GetSqlDatabaseSchema(string strConn)
{
SqlConnection connection = new SqlConnection(strConn);
DataTable schema = new DataTable();
try
{
connection.Open();
schema = connection.GetSchema("TABLES");
}
catch
{
schema = null;
}
finally
{
connection.Close();
}
return schema;
}
TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE |
DB | dbo | StatSystem | BASE TABLE |
DB | dbo | Version | BASE TABLE |
DB | dbo | Advertisement | BASE TABLE |
DB | dbo | UserList | BASE TABLE |
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。