Asp.net获取数据库中所有的表名
作者:互联网
string strConnectionString =System.Configuration.ConfigurationManager.AppSettings["dbconn"];
using (SqlConnection connection = new SqlConnection(strConnectionString))
{
try
{
SqlCommand sqlcmd = new SqlCommand("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'", connection);
connection.Open();
SqlDataReader dr = sqlcmd.ExecuteReader();
while (dr.Read())
{
context.Response.Write(dr.GetString(0));
context.Response.Write("\n");
}
sqlcmd.Dispose();
}
catch (Exception e)
{
context.Response.Write(e.Message);
}
}
context.Response.Write("----------------------------");
标签:Asp,Write,sqlcmd,context,表名,TABLE,net,dr,Response 来源: https://blog.csdn.net/bestxx2009/article/details/118876116