Esempio n. 1
0
        /// <summary>
        /// 不带参数的存储过程
        /// </summary>
        /// <param name="cmdText"></param>
        /// <returns></returns>
        public DataSet GetDataSetPro(string cmdText)
        {
            var connDic = new ConnectionHelper().GetConnectionDic();

            switch (connDic["provider"])
            {
            case "System.Data.SqlClient":
                var sqlHelper = new SqlHelper();
                sqlHelper.ConnectionString = connDic["connectionstring"];
                return(sqlHelper.GetDataSetPro(cmdText));

                break;

            case "MySql.Data.MySqlClient":
                var mySqlHelper = new MySqlHelper();
                mySqlHelper.ConnectionString = connDic["connectionstring"];
                return(mySqlHelper.GetDataSetPro(cmdText));

                break;

            case "System.Data.OracleClient":
                var oraclHelper = new OracleHelper();
                oraclHelper.ConnectionString = connDic["connectionstring"];
                return(oraclHelper.GetDataSetPro(cmdText));

                break;
            }
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// 带参数的存储过程
        /// </summary>
        /// <param name="cmdText"></param>
        /// <param name="spr"></param>
        /// <returns></returns>
        public DataSet GetDataSetPro(string cmdText, List <SqlParameter> spr)
        {
            GetParameters(spr);
            var connDic = new ConnectionHelper().GetConnectionDic();

            switch (connDic["provider"])
            {
            case "System.Data.SqlClient":
                var sqlHelper = new SqlHelper();
                sqlHelper.ConnectionString = connDic["connectionstring"];
                return(sqlHelper.GetDataSetPro(cmdText, sqlserverParamList));

                break;

            case "MySql.Data.MySqlClient":
                var mySqlHelper = new MySqlHelper();
                mySqlHelper.ConnectionString = connDic["connectionstring"];
                return(mySqlHelper.GetDataSetPro(cmdText, mysqlParamList));

                break;

            case "System.Data.OracleClient":
                var oraclHelper = new OracleHelper();
                oraclHelper.ConnectionString = connDic["connectionstring"];
                return(oraclHelper.GetDataSetPro(cmdText, oraclParamList));

                break;
            }
            return(null);
        }
Esempio n. 3
0
        /// <summary>
        /// 带参数的存储过程
        /// </summary>
        /// <param name="cmdText"></param>
        /// <param name="spr"></param>
        /// <returns></returns>
        public static List <Dictionary <string, object> > GetDataSetPro(string cmdText, List <SqlParameter> spr)
        {
            List <Dictionary <string, object> > resDics = new List <Dictionary <string, object> >();
            var connDics = new ConnectionHelper().GetOrgConnDic();

            foreach (var dic in connDics)
            {
                Dictionary <string, object> resDic = new Dictionary <string, object>();
                resDic["code"] = dic["code"];
                resDic["name"] = dic["name"];


                GetParameters(dic, spr);
                switch (dic["provider"])
                {
                case "System.Data.SqlClient":
                    var sqlHelper = new SqlHelper();
                    sqlHelper.ConnectionString = dic["connectionstring"];
                    resDic["data"]             = sqlHelper.GetDataSetPro(cmdText, sqlserverParamList);
                    break;

                case "MySql.Data.MySqlClient":
                    var mySqlHelper = new MySqlHelper();
                    mySqlHelper.ConnectionString = dic["connectionstring"];
                    resDic["data"] = mySqlHelper.GetDataSetPro(cmdText, mysqlParamList);
                    break;

                case "System.Data.OracleClient":
                    var oraclHelper = new OracleHelper();
                    oraclHelper.ConnectionString = dic["connectionstring"];
                    resDic["data"] = oraclHelper.GetDataSetPro(cmdText, oraclParamList);
                    break;
                }
                resDics.Add(resDic);
            }
            return(resDics);
        }