Example #1
0
        /// <summary>
        /// 判断含有@TableName的存储过程在被执行之后
        /// 是否成功创建了临时表,如果没有创建则抛出异常
        /// </summary>
        /// <param name="cmd">执行存储过程的SqlCommand对象</param>
        private void CheckWhetherHadCreatedTempTable(SqlCommand cmd)
        {
            string tableName = this._tempTableName.ToLower().Replace("tempdb..", string.Empty);

            if ((!string.IsNullOrEmpty(tableName)) && tableName.StartsWith("[") && tableName.EndsWith("]"))
            {
                tableName = tableName.Substring(1, tableName.Length - 2);
            }
            if (!SqlHelper.IsTableExsited(tableName, this._loginInfor.TempDBCnnString))
            {
                string exMsg = SqlCommandHelper.GetMsgWhenStoreProcedureError(cmd, null);
                throw new TempDBServiceException(
                          "执行了含有@TableName参数的存储过程,但是存储过程内部没有成功创建临时表",
                          exMsg);
            }
        }
Example #2
0
        private void Storeprocedure2TempTable(
            SqlCommand cmd,
            string tempTableName)
        {
            SqlDataReader reader = null;

            try
            {
                reader = SqlHelper.ExecuteReader(
                    this._loginInfor.UfDataCnnString,
                    cmd);
            }
            catch (Exception e)
            {
                string exMsg = SqlCommandHelper.GetMsgWhenStoreProcedureError(cmd, e);
                throw new TempDBServiceException(e, exMsg);
            }
            this.Reader2TempTable(reader, tempTableName);
        }