C# 动态连接库之数据库执行

namespace ToolsLoad
{
    namespace SQL
    {
        public class Execute
        {
            #region  代码中用到的变量
            Link link = null;
            SqlConnection CON;
            SqlCommand COM;
            SqlDataReader SDR = null;
            SqlDataAdapter SDA;
            DataSet DS = null;
            bool bl = false;
            int num = -1;
            #endregion

            #region  返回BOOL类型的执行方法

            #region  普通的

            #region  需要Connection连接和SQL执行语句的执行方法
            /// <summary>
            /// 需要Connection连接和SQL执行语句的执行方法
            /// </summary>
            /// <param name="con">数据库连接</param>
            /// <param name="sqlstr">SQL执行语句或存储过程名</param>
            /// <returns>bool</returns>
            public bool ExeBool(SqlConnection con, string sqlstr)
            {
                try
                {
                    COM = new SqlCommand(sqlstr, con);
                    num = COM.ExecuteNonQuery();
                    if (num > 0)
                        bl = true;
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(con); }
                return bl;
            }
            #endregion

            #region  需要连接字符串和SQL执行语句的执行方法
            /// <summary>
            /// 需要连接字符串和SQL执行语句的执行方法
            /// </summary>
            /// <param name="linkStr">连接字符串</param>
            /// <param name="sqlstr">SQL执行语句或存储过程名</param>
            /// <returns>bool</returns>
            public bool ExeBool(string linkStr, string sqlstr)
            {
                try
                {
                    link = new link(linkStr);
                    CON = link.ConOpen();
                    bl = ExeBool(CON, sqlstr);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return bl;
            }
            #endregion

            #region  需要SQL服务、数据库名、登录名、密码及SQL执行语句的执行方法
            /// <summary>
            /// 需要SQL服务、数据库名、登录名、密码及SQL执行语句的执行方法
            /// </summary>
            /// <param name="server">服务名</param>
            /// <param name="Name">数据库名</param>
            /// <param name="uid">数据库登录名</param>
            /// <param name="pwd">数据库登录密码</param>
            /// <param name="sqlstr">SQL执行语句</param>
            /// <returns>bool</returns>
            public bool ExeBool(string server, string Name, string uid, string pwd, string sqlstr)
            {
                try
                {
                    link = new link(server, Name, uid, pwd);
                    CON = link.ConOpen();
                    bl = ExeBool(CON, sqlstr);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return bl;
            }
            #endregion

            #region  需要数据源、数据库名、是否使用连接池及SQL执行语句的执行方法
            /// <summary>
            /// 需要数据源、数据库名、是否使用连接池及SQL执行语句的执行方法
            /// </summary>
            /// <param name="dataSource">数据源</param>
            /// <param name="Name">数据库名</param>
            /// <param name="boolSecurity">是否使用连接池</param>
            /// <param name="sqlstr">SQL执行语句</param>
            /// <returns>bool</returns>
            public bool ExeBool(string dataSource, string Name, string boolSecurity, string sqlstr)
            {
                try
                {
                    link = new link(dataSource, Name, boolSecurity);
                    CON = link.ConOpen();
                    bl = ExeBool(CON, sqlstr);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return bl;
            }
            #endregion

            #endregion

            #region  Parameter的

            #region  需要Connection连接和SQL执行语句的parameter执行方法
            /// <summary>
            /// 需要Connection连接和SQL执行语句的parameter执行方法
            /// </summary>
            /// <param name="con">数据库连接</param>
            /// <param name="sqlstr">SQL执行语句或存储过程名</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>bool</returns>
            public bool ExeBool(SqlConnection con, string sqlstr, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    COM = new SqlCommand(sqlstr, con);
                    if (isProcedure)
                    {
                        //定义命令类型
                        COM.CommandType = CommandType.StoredProcedure;
                    }
                    if (values != null)
                    {
                        COM.Parameters.AddRange(values);
                    }
                    num = COM.ExecuteNonQuery();
                    if (num > 0)
                        bl = true;
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(con); }
                return bl;
            }
            #endregion

            #region  需要连接字符串和SQL执行语句的parameter执行方法
            /// <summary>
            /// 需要连接字符串和SQL执行语句的parameter执行方法
            /// </summary>
            /// <param name="linkStr">连接字符串</param>
            /// <param name="sqlstr">SQL执行语句或存储过程名</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>bool</returns>
            public bool ExeBool(string linkStr, string sqlstr, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    link = new link(linkStr);
                    CON = link.ConOpen();
                    bl = ExeBool(CON, sqlstr, isProcedure, values);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return bl;
            }
            #endregion

            #region  需要数据源、数据库名、是否使用连接池和SQL执行语句的parameter执行方法
            /// <summary>
            /// 需要数据源、数据库名、是否使用连接池和SQL执行语句的parameter执行方法
            /// </summary>
            /// <param name="dataSource">数据源</param>
            /// <param name="Name">数据库名</param>
            /// <param name="boolSecurity">是否使用连接池</param>
            /// <param name="sqlstr">SQL执行语句或存储过程名</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>bool</returns>
            public bool ExeBool(string dataSource, string Name, string boolSecurity, string sqlstr, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    link = new link(dataSource, Name, boolSecurity);
                    CON = link.ConOpen();
                    bl = ExeBool(CON, sqlstr, isProcedure, values);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return bl;
            }
            #endregion

            #region  需要SQL服务、数据库名、登录名、密码和SQL执行语句的parameter执行方法
            /// <summary>
            /// 需要SQL服务、数据库名、登录名、密码和SQL执行语句的parameter执行方法
            /// </summary>
            /// <param name="server">服务名</param>
            /// <param name="Name">数据库名</param>
            /// <param name="uid">数据库登录名</param>
            /// <param name="pwd">数据库登录密码</param>
            /// <param name="sqlstr">SQL执行语句或存储过程名</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>bool</returns>
            public bool ExeBool(string server, string Name, string uid, string pwd, string sqlstr, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    link = new link(server, Name, uid, pwd);
                    CON = link.ConOpen();
                    bl = ExeBool(CON, sqlstr, isProcedure, values);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return bl;
            }
            #endregion

            #endregion

            #endregion

            #region  返回INT类型的执行方法

            #region  普通的

            #region  需要Connection连接和SQL执行语句的执行方法
            /// <summary>
            /// 需要Connection连接和SQL执行语句的执行方法
            /// </summary>
            /// <param name="con">Connection连接</param>
            /// <param name="sqlstr">SQL执行语句</param>
            /// <returns>int</returns>
            public int ExeInt(SqlConnection con, string sqlstr)
            {
                try
                {
                    COM = new SqlCommand(sqlstr, con);
                    num = COM.ExecuteNonQuery();
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(con); }
                return num;
            }
            #endregion

            #region  需要连接字符串和SQL执行语句的执行方法
            /// <summary>
            /// 需要连接字符串和SQL执行语句的执行方法
            /// </summary>
            /// <param name="linkStr">连接字符串</param>
            /// <param name="sqlstr">SQL执行语句</param>
            /// <returns>int</returns>
            public int ExeInt(string linkStr, string sqlstr)
            {
                try
                {
                    link = new link(linkStr);
                    CON = link.ConOpen();
                    num = ExeInt(CON, sqlstr);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return num;
            }
            #endregion

            #region  需要SQL服务、数据库名、登录名、密码及SQL执行语句的执行方法
            /// <summary>
            /// 需要SQL服务、数据库名、登录名、密码及SQL执行语句的执行方法
            /// </summary>
            /// <param name="server">SQL服务</param>
            /// <param name="Name">数据库名</param>
            /// <param name="uid">登录名</param>
            /// <param name="pwd">密码</param>
            /// <param name="sqlstr">SQL执行语句</param>
            /// <returns>int</returns>
            public int ExeInt(string server, string Name, string uid, string pwd, string sqlstr)
            {
                try
                {
                    link = new link(server, Name, uid, pwd);
                    CON = link.ConOpen();
                    num = ExeInt(CON, sqlstr);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return num;
            }
            #endregion

            #region   需要数据源、数据库名、是否使用连接池及SQL执行语句的执行方法
            /// <summary>
            /// 需要数据源、数据库名、是否使用连接池及SQL执行语句的执行方法
            /// </summary>
            /// <param name="dataSource">数据源</param>
            /// <param name="Name">数据库名</param>
            /// <param name="boolSecurity">是否使用连接池</param>
            /// <param name="sqlstr">SQL执行语句</param>
            /// <returns>int</returns>
            public int ExeInt(string dataSource, string Name, string boolSecurity, string sqlstr)
            {
                try
                {
                    link = new link(dataSource, Name, boolSecurity);
                    CON = link.ConOpen();
                    num = ExeInt(CON, sqlstr);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return num;
            }
            #endregion

            #endregion

            #region  Parameter的

            #region  需要Connection连接和SQL执行语句的parameter执行方法
            /// <summary>
            /// 需要Connection连接和SQL执行语句的parameter执行方法
            /// </summary>
            /// <param name="con">数据库连接</param>
            /// <param name="sqlstr">SQL执行语句或存储过程名</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>int</returns>
            public int ExeInt(SqlConnection con, string sqlstr, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    COM = new SqlCommand(sqlstr, con);
                    if (isProcedure)
                    {
                        //定义命令类型
                        COM.CommandType = CommandType.StoredProcedure;
                    }
                    if (values != null)
                    {
                        COM.Parameters.AddRange(values);
                    }
                    num = COM.ExecuteNonQuery();
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(con); }
                return num;
            }
            #endregion

            #region  需要连接字符串和SQL执行语句的parameter执行方法
            /// <summary>
            /// 需要连接字符串和SQL执行语句的parameter执行方法
            /// </summary>
            /// <param name="linkStr">连接字符串</param>
            /// <param name="sqlstr">SQL执行语句或存储过程名</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>int</returns>
            public int ExeInt(string linkStr, string sqlstr, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    link = new link(linkStr);
                    CON = link.ConOpen();
                    num = ExeInt(CON, sqlstr, isProcedure, values);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return num;
            }
            #endregion

            #region  需要数据源、数据库名、是否使用连接池和SQL执行语句的parameter执行方法
            /// <summary>
            /// 需要数据源、数据库名、是否使用连接池和SQL执行语句的parameter执行方法
            /// </summary>
            /// <param name="dataSource">数据源</param>
            /// <param name="Name">数据库名</param>
            /// <param name="boolSecurity">是否使用连接池</param>
            /// <param name="sqlstr">SQL执行语句或存储过程名</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>int</returns>
            public int ExeInt(string dataSource, string Name, string boolSecurity, string sqlstr, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    link = new link(dataSource, Name, boolSecurity);
                    CON = link.ConOpen();
                    num = ExeInt(CON, sqlstr, isProcedure, values);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return num;
            }
            #endregion

            #region  需要SQL服务、数据库名、登录名、密码和SQL执行语句的parameter执行方法
            /// <summary>
            /// 需要SQL服务、数据库名、登录名、密码和SQL执行语句的parameter执行方法
            /// </summary>
            /// <param name="server">服务名</param>
            /// <param name="Name">数据库名</param>
            /// <param name="uid">数据库登录名</param>
            /// <param name="pwd">数据库登录密码</param>
            /// <param name="sqlstr">SQL执行语句或存储过程名</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>int</returns>
            public int ExeInt(string server, string Name, string uid, string pwd, string sqlstr, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    link = new link(server, Name, uid, pwd);
                    CON = link.ConOpen();
                    num = ExeInt(CON, sqlstr, isProcedure, values);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return num;
            }
            #endregion

            #endregion

            #endregion

            #region  执行查询的方法返回DataSet结果集

            #region  普通的

            #region  需要Connection连接和SQL查询语句的查询方法
            /// <summary>
            /// 需要Connection连接和SQL查询语句的查询方法
            /// </summary>
            /// <param name="con">Connection连接</param>
            /// <param name="sqlSelect">SQL查询语句</param>
            /// <returns>DataSet结果集</returns>
            public DataSet DsSelect(SqlConnection con, string sqlSelect)
            {
                try
                {
                    SDA = new SqlDataAdapter(sqlSelect, con);
                    DS = new DataSet();
                    DS.Clear();
                    SDA.Fill(DS);
                }
                catch (Exception e)
                { throw e; }
                finally
                { con.Close(); }
                return DS;
            }
            #endregion

            #region  需要连接字符串和SQL查询语句的执行方法
            /// <summary>
            /// 需要连接字符串和SQL执行语句的执行方法
            /// </summary>
            /// <param name="linkStr">连接字符串</param>
            /// <param name="sqlSelect">SQL查询语句</param>
            /// <returns>DataSet结果集</returns>
            public DataSet DsSelect(string linkStr, string sqlSelect)
            {
                try
                {
                    link = new link(linkStr);
                    CON = link.ConOpen();
                    DS = DsSelect(CON, sqlSelect);
                }
                catch (Exception e)
                { throw e; }
                return DS;
            }
            #endregion

            #region  需要SQL服务、数据库名、登录名、密码及SQL查询语句的执行方法
            /// <summary>
            /// 需要SQL服务、数据库名、登录名、密码及SQL执行语句的执行方法
            /// </summary>
            /// <param name="server">SQL服务</param>
            /// <param name="Name">数据库名</param>
            /// <param name="uid">登录名</param>
            /// <param name="pwd">密码</param>
            /// <param name="sqlSelect">SQL查询语句</param>
            /// <returns>DataSet结果集</returns>
            public DataSet DsSelect(string server, string Name, string uid, string pwd, string sqlSelect)
            {
                try
                {
                    link = new link(server, Name, uid, pwd);
                    CON = link.ConOpen();
                    DS = DsSelect(CON, sqlSelect);
                }
                catch (Exception e)
                { throw e; }
                return DS;
            }
            #endregion

            #region  需要数据源、数据库名、是否使用连接池及SQL查询语句的执行方法
            /// <summary>
            /// 需要数据源、数据库名、是否使用连接池及SQL执行语句的执行方法
            /// </summary>
            /// <param name="dataSource">数据源</param>
            /// <param name="Name">数据库名</param>
            /// <param name="boolSecurity"></param>
            /// <param name="sqlSelect">SQL查询语句</param>
            /// <returns>DataSet结果集</returns>
            public DataSet DsSelect(string dataSource, string Name, string boolSecurity, string sqlSelect)
            {
                try
                {
                    link = new link(dataSource, Name, boolSecurity);
                    CON = link.ConOpen();
                    DS = DsSelect(CON, sqlSelect);
                }
                catch (Exception e)
                { throw e; }
                return DS;
            }
            #endregion

            #endregion

            #region  Parameter的

            #region  需要Connection连接和SQL查询语句的parameter查询方法
            /// <summary>
            /// 需要Connection连接和SQL查询语句的parameter查询方法
            /// </summary>
            /// <param name="con">数据库连接</param>
            /// <param name="sqlstr">SQL查询语句或存储过程名</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>DataSet结果集</returns>
            public DataSet DsSelect(SqlConnection con, string sqlSelect, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    DS = new DataSet();
                    SDA = new SqlDataAdapter(sqlSelect,con);
                    if (isProcedure)
                    {
                        //定义命令类型
                        SDA.SelectCommand.CommandType = CommandType.StoredProcedure;
                    }
                    if (values != null)
                    {
                        SDA.SelectCommand.Parameters.AddRange(values);
                    }
                    DS.Clear();
                    SDA.Fill(DS);
                }
                catch (Exception e)
                { throw e; }
                finally
                { con.Close(); }
                return DS;
            }
            #endregion

            #region  需要连接字符串和SQL查询语句的parameter查询方法
            /// <summary>
            /// 需要连接字符串和SQL查询语句的parameter查询方法
            /// </summary>
            /// <param name="linkStr">连接字符串</param>
            /// <param name="sqlSelect">SQL查询语句或存储过程</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>DataSet结果集</returns>
            public DataSet DsSelect(string linkStr, string sqlSelect, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    link = new link(linkStr);
                    CON = link.ConOpen();
                    DS = DsSelect(CON, sqlSelect, isProcedure, values);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return DS;
            }
            #endregion

            #region  需要SQL服务、数据库名、登录名、密码和SQL查询语句的parameter查询方法
            /// <summary>
            /// 需要SQL服务、数据库名、登录名、密码和SQL查询语句的parameter查询方法
            /// </summary>
            /// <param name="server">SQL服务</param>
            /// <param name="Name">数据库名</param>
            /// <param name="uid">登录名</param>
            /// <param name="pwd">密码</param>
            /// <param name="sqlSelect">SQL查询语句或存储过程</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>DataSet结果集</returns>
            public DataSet DsSelect(string server, string Name, string uid, string pwd, string sqlSelect, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    link = new link(server, Name, uid, pwd);
                    CON = link.ConOpen();
                    DS = DsSelect(CON, sqlSelect, isProcedure, values);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return DS;
            }
            #endregion

            #region  需要数据源、数据库名、是否使用连接池和SQL查询语句的parameter查询方法
            /// <summary>
            /// 需要数据源、数据库名、是否使用连接池和SQL查询语句的parameter查询方法
            /// </summary>
            /// <param name="dataSource">数据源</param>
            /// <param name="Name">数据库名</param>
            /// <param name="boolSecurity"></param>
            /// <param name="sqlSelect">SQL查询语句或存储过程</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>DataSet结果集</returns>
            public DataSet DsSelect(string dataSource, string Name, string boolSecurity, string sqlSelect, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    link = new link(dataSource, Name, boolSecurity);
                    CON = link.ConOpen();
                    DS = DsSelect(CON, sqlSelect, isProcedure, values);
                }
                catch (Exception e)
                { throw e; }
                finally
                { link.ConClose(CON); }
                return DS;
            }
            #endregion

            #endregion

            #endregion

            #region  执行查询的方法返回SqlDataReader读取流

            #region  普通的

            #region  需要Connection连接和SQL查询语句的查询方法
            /// <summary>
            /// 需要Connection连接和SQL查询语句的查询方法
            /// </summary>
            /// <param name="con">Connection连接</param>
            /// <param name="sqlSelect">SQL查询语句</param>
            /// <returns>DataReader流</returns>
            public SqlDataReader ReadSelect(SqlConnection con, string sqlSelect)
            {
                try
                {
                    COM = new SqlCommand(sqlSelect, con);
                    SDR = COM.ExecuteReader();
                }
                catch (Exception e)
                { throw e; }
                return SDR;
            }
            #endregion

            #region  需要连接字符串和SQL查询语句的查询方法
            /// <summary>
            /// 需要连接字符串和SQL查询语句的查询方法
            /// </summary>
            /// <param name="linkStr">连接字符串</param>
            /// <param name="sqlSelect">SQL查询语句</param>
            /// <returns>DataReader流</returns>
            public SqlDataReader ReadSelect(string linkStr, string sqlSelect)
            {
                try
                {
                    link = new link(linkStr);
                    CON = link.ConOpen();
                    SDR = ReadSelect(CON, sqlSelect);
                }
                catch (Exception e)
                { throw e; }
                return SDR;
            }
            #endregion

            #region  需要SQL服务、数据库名、登录名、密码及SQL执行语句的查询方法
            /// <summary>
            /// 需要SQL服务、数据库名、登录名、密码及SQL执行语句的查询方法
            /// </summary>
            /// <param name="server">SQL服务</param>
            /// <param name="Name">数据库名</param>
            /// <param name="uid">登录名</param>
            /// <param name="pwd">密码</param>
            /// <param name="sqlSelect">SQL查询语句</param>
            /// <returns>DataReader流</returns>
            public SqlDataReader ReadSelect(string server, string Name, string uid, string pwd, string sqlSelect)
            {
                try
                {
                    link = new link(server, Name, uid, pwd);
                    CON = link.ConOpen();
                    SDR = ReadSelect(CON, sqlSelect);
                }
                catch (Exception e)
                { throw e; }
                return SDR;
            }
            #endregion

            #region  需要数据源、数据库名、是否使用连接池及SQL执行语句的查询方法
            /// <summary>
            /// 需要数据源、数据库名、是否使用连接池及SQL执行语句的查询方法
            /// </summary>
            /// <param name="dataSource">数据源</param>
            /// <param name="Name">数据库名</param>
            /// <param name="boolSecurity">是否使用连接池</param>
            /// <param name="sqlSelect">SQL查询语句</param>
            /// <returns>DataReader流</returns>
            public SqlDataReader ReadSelect(string dataSource, string Name, string boolSecurity, string sqlSelect)
            {
                try
                {
                    link = new link(dataSource, Name, boolSecurity);
                    CON = link.ConOpen();
                    SDR = ReadSelect(CON, sqlSelect);
                }
                catch (Exception e)
                { throw e; }
                return SDR;
            }
            #endregion

            #endregion

            #region  parameter的

            #region  需要Connection连接和SQL查询语句的parameter查询方法
            /// <summary>
            /// 需要Connection连接和SQL查询语句的的parameter查询方法
            /// </summary>
            /// <param name="con">数据库连接</param>
            /// <param name="sqlSelect">SQL查询语句或存储过程名</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>DataReader流</returns>
            public SqlDataReader ReadSelect(SqlConnection con, string sqlSelect, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    COM = new SqlCommand(sqlSelect, con);
                    if (isProcedure)
                    {
                        //定义命令类型
                        COM.CommandType = CommandType.StoredProcedure;
                    }
                    if (values != null)
                    {
                        COM.Parameters.AddRange(values);
                    }
                    SDR = COM.ExecuteReader();
                }
                catch (Exception e)
                { throw e; }
                return SDR;
            }
            #endregion

            #region  需要连接字符串和SQL查询语句的parameter查询方法
            /// <summary>
            /// 需要连接字符串和SQL查询语句的parameter查询方法
            /// </summary>
            /// <param name="linkStr">连接字符串</param>
            /// <param name="sqlSelect">SQL查询语句或存储过程</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>DataReader流</returns>
            public SqlDataReader ReadSelect(string linkStr, string sqlSelect, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    link = new link(linkStr);
                    CON = link.ConOpen();
                    SDR = ReadSelect(CON, sqlSelect, isProcedure, values);
                }
                catch (Exception e)
                { throw e; }
                return SDR;
            }
            #endregion

            #region  需要SQL服务、数据库名、登录名、密码及SQL执行语句的parameter查询方法
            /// <summary>
            /// 需要SQL服务、数据库名、登录名、密码及SQL执行语句的parameter查询方法
            /// </summary>
            /// <param name="server">SQL服务</param>
            /// <param name="Name">数据库名</param>
            /// <param name="uid">登录名</param>
            /// <param name="pwd">密码</param>
            /// <param name="sqlSelect">SQL查询语句或存储过程</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>DataReader流</returns>
            public SqlDataReader ReadSelect(string server, string Name, string uid, string pwd, string sqlSelect, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    link = new link(server, Name, uid, pwd);
                    CON = link.ConOpen();
                    SDR = ReadSelect(CON, sqlSelect, isProcedure, values);
                }
                catch (Exception e)
                { throw e; }
                return SDR;
            }
            #endregion

            #region  需要数据源、数据库名、是否使用连接池及SQL执行语句的parameter查询方法
            /// <summary>
            /// 需要数据源、数据库名、是否使用连接池及SQL执行语句的parameter查询方法
            /// </summary>
            /// <param name="dataSource">数据源</param>
            /// <param name="Name">数据库名</param>
            /// <param name="boolSecurity">是否使用连接池</param>
            /// <param name="sqlSelect">SQL查询语句或存储过程</param>
            /// <param name="isProcedure">是否是存储过程</param>
            /// <param name="values">参数</param>
            /// <returns>DataReader流</returns>
            public SqlDataReader ReadSelect(string dataSource, string Name, string boolSecurity, string sqlSelect, bool isProcedure, params SqlParameter[] values)
            {
                try
                {
                    link = new link(dataSource, Name, boolSecurity);
                    CON = link.ConOpen();
                    SDR = ReadSelect(CON, sqlSelect, isProcedure, values);
                }
                catch (Exception e)
                { throw e; }
                return SDR;
            }
            #endregion

            #endregion

            #endregion
        }
    }

}

posted on 2010-04-13 22:49  VictorShan  阅读(1564)  评论(0编辑  收藏

导航

统计