数据库连接如下:
<add key="BusinessDbConnection" value="Data Source=localhost;Initial Catalog=PRM;User Id = sa ; Password = "@sa;" />
代码如下:
//
--------------------------------------------------------------------
// All Rights Reserved , Copyright (C) 2011 , Hairihan TECH, Ltd.
// --------------------------------------------------------------------
using System.Data;
using System.Data.SqlClient;
namespace DotNet.Example
{
using DotNet.BaseManager;
using DotNet.Utilities;
using DotNet.DbUtilities;
public class SchemaTable
{
public void GetSchemaTable()
{
SqlConnection connection = new SqlConnection(BaseSystemInfo.BusinessDbConnection);
connection.Open();
DataTable dt = connection.GetSchema( " Tables ");
connection.Close();
foreach (DataRow dataRow in dt.Rows)
{
string tableName = dataRow[ " TABLE_NAME "].ToString();
string commandText = " SELECT COUNT(*) FROM " + tableName;
int rowCount = int.Parse(DbHelper.ExecuteScalar(commandText).ToString());
if (rowCount > 1000)
{
System.Console.WriteLine( " {0,8} {1} ", rowCount, tableName);
}
}
}
}
}
// All Rights Reserved , Copyright (C) 2011 , Hairihan TECH, Ltd.
// --------------------------------------------------------------------
using System.Data;
using System.Data.SqlClient;
namespace DotNet.Example
{
using DotNet.BaseManager;
using DotNet.Utilities;
using DotNet.DbUtilities;
public class SchemaTable
{
public void GetSchemaTable()
{
SqlConnection connection = new SqlConnection(BaseSystemInfo.BusinessDbConnection);
connection.Open();
DataTable dt = connection.GetSchema( " Tables ");
connection.Close();
foreach (DataRow dataRow in dt.Rows)
{
string tableName = dataRow[ " TABLE_NAME "].ToString();
string commandText = " SELECT COUNT(*) FROM " + tableName;
int rowCount = int.Parse(DbHelper.ExecuteScalar(commandText).ToString());
if (rowCount > 1000)
{
System.Console.WriteLine( " {0,8} {1} ", rowCount, tableName);
}
}
}
}
}
希望能起点而参考作用.
本文转自 jirigala 51CTO博客,原文链接:http://blog.51cto.com/2347979/1197306,如需转载请自行联系原作者