Ejemplo n.º 1
0
        public DataTable ExecuteDataTable(ref ExecuteParams paras, out bool isHaveOutParams)
        {
            DataTable dtTable = null;
            using (DbConnection cn = DBHelper.OpenConnection(this.ConnectionString))
            {
                using (DbCommand cmd = cn.CreateCommandStoredProc(paras.SPName))
                {
                    var inputParams = paras.SQLParams.FindAll(p => !p.IsOutput);
                    foreach (SQLParam param in inputParams)
                    {
                        DbType dbType = DBHelper.GetDBType(param.DBType);
                        cmd.AddInParameter(param.Name, dbType, param.Value);
                    }

                    var outParams = paras.SQLParams.FindAll(p => p.IsOutput);
                    foreach (SQLParam param in outParams)
                    {
                        DbType dbType = DBHelper.GetDBType(param.DBType);
                        param.DBParam = cmd.AddOutParameter(param.Name, dbType, param.Size);
                    }

                    isHaveOutParams = outParams.Count > 0;
                    dtTable = cmd.ExcuteDataTable();
                }
            }

            return dtTable;
        }