Backup/DbUtility/SqlHelper.cs

(开头部分) 120KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/*******************************************************************************
             数据库基类                                      
             本类主要实现对数据库操作的各种方法              
             本类来源于互联网,大家有更好更新的版本时可以通知我们!!Aosy.net 
             {2013/4/14}                 
 * *****************************************************************************/
using System;
using System.Data;
using System.Xml;
using System.Data.SqlClient;
using System.Collections;

namespace PR.DbUtility
{
    /// <summary>
    /// SqlServer数据访问帮助类
    /// </summary>
    public sealed class SqlHelper
    {
        #region 私有构造函数和方法

        private SqlHelper() {}

        /// <summary>
        /// 将SqlParameter参数数组(参数值)分配给SqlCommand命令.
        /// 这个方法将给任何一个参数分配DBNull.Value;
        /// 该操作将阻止默认值的使用.
        /// </summary>
        /// <param name="command">命令名</param>
        /// <param name="commandParameters">SqlParameters数组</param>
        private static void AttachParameters(SqlCommand command, SqlParameter[] commandParameters)
        {
            if( command == null ) throw new ArgumentNullException( "command" );
            if( commandParameters != null )
            {
                foreach (SqlParameter p in commandParameters)
                {
                    if( p != null )
                    {
                        // 检查未分配值的输出参数,将其分配以DBNull.Value.
                        if ( ( p.Direction == ParameterDirection.InputOutput || p.Direction == ParameterDirection.Input ) && 
                            (p.Value == null))
                        {
                            p.Value = DBNull.Value;
                        }
                        command.Parameters.Add(p);
                    }
                }
            }
        }

        /// <summary>
        /// 将DataRow类型的列值分配到SqlParameter参数数组.
        /// </summary>
        /// <param name="commandParameters">要分配值的SqlParameter参数数组</param>
        /// <param name="dataRow">将要分配给存储过程参数的DataRow</param>
        private static void AssignParameterValues(SqlParameter[] commandParameters, DataRow dataRow)
        {
            if ((commandParameters == null) || (dataRow == null)) 
            {
后面还有 2450 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。