数据库连接如下:
<add key="BusinessDbConnection" value="Data Source=localhost;Initial Catalog=PRM;User Id = sa ; Password = ">
代码如下:
// -------------------------------------------------------------------- // 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); } } } } }
希望能起点而参考作用.