private void RecreateCommand()
 {
     this.FCommand = this.FConnection.CreateCommand();
     this.FCommand.CommandTimeout = this.FCommandTimeout;
     if (this.FTransaction != null)
     {
         this.FCommand.Transaction = this.FTransaction;
     }
     this.FCommand.CommandText = this.FSql;
     if (this.FParamTypes != null)
     {
         for (int index = 0; index < this.FParamTypes.Length; ++index)
         {
             SqlParameter parameter = this.FCommand.CreateParameter();
             parameter.ParameterName = string.Format("@{0}", (object)(index + 1));
             parameter.DbType        = InDbUtils.DataTypeToDbType(this.FParamTypes[index]);
             int fparamMaxSiz = this.FParamMaxSizes[index];
             if (fparamMaxSiz > 0)
             {
                 parameter.Size = fparamMaxSiz;
             }
             this.FCommand.Parameters.Add(parameter);
         }
     }
     this.FCommand.Prepare();
 }
示例#2
0
 internal InDbOracleCommand(
     OracleConnection connection,
     OracleTransaction transaction,
     string sql,
     params DataType[] paramTypes)
 {
     this.FCommand = connection.CreateCommand();
     if (transaction != null)
     {
         this.FCommand.Transaction = transaction;
     }
     sql = OracleSqlPreprocessor.Translate(sql);
     this.FCommand.CommandText = sql;
     this.FParamTypes          = paramTypes;
     if (paramTypes == null)
     {
         return;
     }
     for (int index = 0; index < paramTypes.Length; ++index)
     {
         IDbDataParameter parameter = (IDbDataParameter)this.FCommand.CreateParameter();
         parameter.ParameterName = string.Format("{0}", (object)(index + 1));
         parameter.DbType        = InDbUtils.DataTypeToDbType(paramTypes[index]);
         this.FCommand.Parameters.Add((object)parameter);
     }
 }
 internal InDbSqlCommand(
     SqlConnection connection,
     SqlTransaction transaction,
     int commandTimeout,
     string sql,
     params DataType[] paramTypes)
 {
     this.FConnection     = connection;
     this.FTransaction    = transaction;
     this.FCommandTimeout = commandTimeout;
     this.FSql            = MsSqlPreprocessor.Translate(sql);
     if (paramTypes == null || paramTypes.Length <= 0)
     {
         return;
     }
     this.FParamTypes    = paramTypes;
     this.FParamMaxSizes = new int[paramTypes.Length];
     for (int index = 0; index < paramTypes.Length; ++index)
     {
         if (InDbUtils.IsVariableLengthDataType(paramTypes[index]))
         {
             this.FParamMaxSizes[index] = 1;
         }
     }
 }
示例#4
0
 private void FillParams(params object[] paramValues)
 {
     if (paramValues == null || paramValues.Length <= 0)
     {
         return;
     }
     for (int index = 0; index < this.FParamTypes.Length; ++index)
     {
         IDataParameter parameter  = (IDataParameter)this.FCommand.Parameters[index];
         DataType       fparamType = this.FParamTypes[index];
         object         paramValue = paramValues[index];
         if (paramValue == null || paramValue == DBNull.Value)
         {
             parameter.Value = (object)DBNull.Value;
         }
         else
         {
             object obj = InDbUtils.Convert(paramValues[index], fparamType);
             parameter.Value = obj;
             if (obj != null && (parameter.DbType == DbType.AnsiString || parameter.DbType == DbType.String || parameter.DbType == DbType.Binary))
             {
                 OracleParameter oracleParameter = (OracleParameter)parameter;
                 if (fparamType == DataType.Memo)
                 {
                     oracleParameter.OracleType = OracleType.Clob;
                 }
                 oracleParameter.Size = ((string)obj).Length + 1;
             }
         }
     }
 }
 private void FillParams(params object[] paramValues)
 {
     if (this.FParamTypes == null || paramValues == null || paramValues.Length == 0)
     {
         if (this.FCommand != null)
         {
             return;
         }
         this.RecreateCommand();
     }
     else
     {
         object[] objArray = new object[paramValues.Length];
         for (int index = 0; index < this.FParamTypes.Length; ++index)
         {
             DataType fparamType = this.FParamTypes[index];
             object   paramValue = paramValues[index];
             if (paramValue == null || paramValue == DBNull.Value)
             {
                 objArray[index] = (object)DBNull.Value;
             }
             else
             {
                 object obj = InDbUtils.Convert(paramValue, fparamType);
                 objArray[index] = obj;
                 int fparamMaxSiz = this.FParamMaxSizes[index];
                 if (fparamMaxSiz > 0)
                 {
                     int num = obj is string?((string)obj).Length : ((byte[])obj).Length;
                     if (num > fparamMaxSiz)
                     {
                         if (num > 4000 && num <= 8000)
                         {
                             num = 8001;
                         }
                         this.FParamMaxSizes[index] = num;
                         if (this.FCommand != null)
                         {
                             this.FCommand.Dispose();
                             this.FCommand = (SqlCommand)null;
                         }
                     }
                 }
             }
         }
         if (this.FCommand == null)
         {
             this.RecreateCommand();
         }
         for (int index = 0; index < objArray.Length; ++index)
         {
             this.FCommand.Parameters[index].Value = objArray[index];
         }
     }
 }