日期:2014-05-18 浏览次数:20382 次
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace ClassLib
{
public class OperationSQL
{
public OperationSQL()
{
}
/// <summary>
/// 获得所有数据库名称
/// </summary>
/// <param name="connectionString">连接字符串 </param>
/// <param name="isunion">是否新增‘--All Database--’行 </param>
/// <returns>所有数据库名称 </returns>
public static DataSet GetAllDataBase(string connectionString, bool isunion)
{
string strSql = "select [name] from sysdatabases union select '--All Database--' as name";
if (!isunion)
{
strSql = "select [name] from sysdatabases order by name";
}
DbHelperSQL.connectionString = connectionString;
return DbHelperSQL.Query(strSql);
}
/// <summary>
/// 获得指定数据库中的所有的表
/// </summary>
/// <param name="connection">连接 </param>
/// <returns>指定数据库中的所有的表 </returns>
public static DataSet GetAll(SqlConnection connection)
{
string strSql = "select [name] from sysObjects where xtype='V' or xtype='P' or xtype='U'and [name] <>'dtproperties' order by [name]";
return DbHelperSQL.Query(strSql, connection);
}
/// <summary>
/// 获得指定数据库中的所有的表
/// </summary>
/// <param name="connection">连接 </param>
/// <returns>指定数据库中的所有的表 </returns>
public static DataSet GetAllTable(SqlConnection connection)
{
string strSql = "select [name] from sysObjects where xtype='U'and [name] <>'dtproperties' order by [name]";
return DbHelperSQL.Query(strSql, connection);
}
/// <summary>
/// 获得指定数据库中的所有的视图
/// </summary>
/// <param name="connection">连接 </param>
/// <returns>指定数据库中的所有的视图 </returns>
public static DataSet GetAllView(SqlConnection connection)
{
string strSql = "select [name] from sysObjects where xtype='V' order by [name]";
return DbHelperSQL.Query(strSql, connection);
}
/// <summary>
/// 获得指定数据库中的所有的存储过程
/// </summary>
/// <param name="connection">连接 </param>
/// <returns>指定数据库中的所有的存储过程 </returns>
public static D