当前位置: 首页>>代码示例>>C#>>正文


C# Database.AddParameter方法代码示例

本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.Data.Database.AddParameter方法的典型用法代码示例。如果您正苦于以下问题:C# Database.AddParameter方法的具体用法?C# Database.AddParameter怎么用?C# Database.AddParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Practices.EnterpriseLibrary.Data.Database的用法示例。


在下文中一共展示了Database.AddParameter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildDBParameterForReturnValue

 /// <summary>
 /// 为储存过程加载输出变量参数
 /// </summary>
 /// <param name="db">database</param>
 /// <param name="dbCommand">db command</param>
 /// <param name="cmdParms">参数数组</param>
 public static void BuildDBParameterForReturnValue(Database db, DbCommand dbCommand, params IDataParameter[] cmdParms)
 {
     foreach (SqlParameter sp in cmdParms)
     {
         db.AddParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Size, ParameterDirection.Output, false, 0, 0, sp.SourceColumn, DataRowVersion.Current, DBNull.Value);
     }
 }
开发者ID:yujianjob,项目名称:promotion,代码行数:13,代码来源:MSEntLibSqlHelper.cs

示例2: CreateReturnParameter

        /// <summary>
        ///     Creates a return parameter and inserts into the command list
        /// </summary>
        /// <param name="db">The database object</param>
        /// <param name="cmd">The command object</param>
        /// <remarks>The DBCommand parameter argument that is modified</remarks>
        public static void CreateReturnParameter(Database db, ref DbCommand cmd)
        {
            #region Defensive

            #region db

            Debug.Assert(db != null, "The argument supplied for parameter 'db' should not be null");

            if(db == null)
            {
                throw new ArgumentNullException("db", "The argument supplied for parameter 'db' should not be null");
            }

            #endregion

            #region cmd

            Debug.Assert(cmd != null, "The argument supplied for parameter 'cmd' should not be null");

            if(cmd == null)
            {
                throw new ArgumentNullException("cmd", "The argument supplied for parameter 'cmd' should not be null");
            }

            #endregion

            #endregion

            db.AddParameter(cmd, RETURN_VALUE, DbType.Int32, sizeof(int), ParameterDirection.ReturnValue,
                    false, 0, 0, string.Empty, DataRowVersion.Default, null);
        }
开发者ID:omprsingh,项目名称:CashCow,代码行数:37,代码来源:SqlUtil.cs

示例3: AddOutParameter

 public void AddOutParameter(Database database, string parameterName)
 {
     database.AddParameter(dbCommand, parameterName, DbType.Int32,
        ParameterDirection.ReturnValue, null,
        DataRowVersion.Default, null);
 }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:6,代码来源:ExecuteNonQuery.cs

示例4: AddInParameter

 public void AddInParameter(Database database, object value, string parameterName)
 {
     database.AddParameter(dbCommand, parameterName,
          DbType.String, ParameterDirection.Input,
          null, DataRowVersion.Default, value);
 }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:6,代码来源:ExecuteNonQuery.cs

示例5: RunProcedureWithResult

 /// <summary>
 /// 执行存储过程,获得存储过程的返回值[注:必须在目标存储过程中设置return返回值,否则始终返回0]
 /// </summary>
 /// <param name="dc">存储过程语句</param>
 /// <param name="db">操作目标数据库</param>
 /// <returns></returns>
 public static int RunProcedureWithResult(DbCommand dc, Database db)
 {
     int result = 0;
     try
     {
         PrepareCommand(ref dc, db);
         db.AddParameter(dc, "ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, string.Empty, DataRowVersion.Default, null);
         db.ExecuteNonQuery(dc);
         result = (int)dc.Parameters[db.BuildParameterName("ReturnValue")].Value;
     }
     catch (System.Exception e)
     {
         throw new Exception(e.Message);
     }
     return result;
 }
开发者ID:uwitec,项目名称:O2O,代码行数:22,代码来源:DbHelper.cs

示例6: PrepareCommand

        /// <summary>
        /// Prepare a DbCommand object with its parameters
        /// </summary>
        /// <param name="pStoredProcedureName">Stored procedure name using dbo.Name sintax</param>
        /// <param name="pParameters">Array of cParametroDatos</param>
        /// <param name="pOutputParameters">List of DataParameters that are for output purpose</param>
        /// <param name="pDbAccess">Database Object</param>
        /// <returns>Prepared DbCommand</returns>
        protected virtual DbCommand PrepareCommand(string pStoredProcedureName, IEnumerable<cParametroDatos> pParameters, out IList<cParametroDatos> pOutputParameters, out Database pDbAccess)
        {
            pDbAccess = GetDatabase();
            DbCommand command = pDbAccess.GetStoredProcCommand(pStoredProcedureName);

            pOutputParameters = new List<cParametroDatos>();
            pOutputParameters.Add(new cParametroDatos(RETURN_VALUE, DbType.Int32, ParameterDirection.ReturnValue, 0));

            SqlParameter param = new SqlParameter(RETURN_VALUE, SqlDbType.Int);
            param.Direction = ParameterDirection.ReturnValue;
            command.Parameters.Add(param);

            foreach (cParametroDatos parameter in pParameters)
            {
                pDbAccess.AddParameter(command, parameter.ParameterName, parameter.DbType, parameter.Direction, parameter.ParameterName, DataRowVersion.Current, parameter.Value);
                if (parameter.Direction == ParameterDirection.Output || parameter.Direction == ParameterDirection.InputOutput)
                {
                    pOutputParameters.Add(parameter);
                }
            }
            return command;
        }
开发者ID:jascrer,项目名称:Sistema_de_Inclusiones_IC-ITCR,代码行数:30,代码来源:cAccesoDatos.cs


注:本文中的Microsoft.Practices.EnterpriseLibrary.Data.Database.AddParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。