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.net获取数据库中所有的表名
最新推荐文章于 2022-11-17 11:42:54 发布