Exemplo n.º 1
0
        private static IDbDataParameter CreateParameter(IDbCommand dbCommand, string parameterName,
                                                        DbTypeContainer parameterType, int parameterLength,
                                                        object parameterValue, ParameterDirection parameterDirection)
        {
            IDbDataParameter param;

            param = dbCommand.CreateParameter();
            param.ParameterName = parameterName;

            if (parameterType.IsDbType == true)
            {
                param.DbType = parameterType.DbType.GetValueOrDefault(DbType.Object);
            }
            else
            {
                ((SqlParameter)param).SqlDbType = parameterType.SqlDbType.GetValueOrDefault(SqlDbType.Variant);
            }

            if (parameterLength != Int32.MinValue)
            {
                param.Size = parameterLength;
            }

            param.Value     = parameterValue;
            param.Direction = parameterDirection;

            return(param);
        }
Exemplo n.º 2
0
 private static void AddParameter(IDbCommand dbCommand, string parameterName, DbTypeContainer parameterType,
                                  int parameterLength, object parameterValue,
                                  ParameterDirection parameterDirection)
 {
     dbCommand.Parameters.Add(
         CreateParameter(dbCommand, parameterName, parameterType, parameterLength, parameterValue,
                         parameterDirection));
 }