Exemplo n.º 1
0
 public DBParameter(string name, object value, DBParameterType paramType, string sourceColumn)
 {
     _paramName    = name;
     _paramValue   = value;
     _paramType    = paramType;
     _sourceColumn = sourceColumn;
 }
Exemplo n.º 2
0
        private static OracleDbType GetParameterType(DBParameterType parameterType, object value)
        {
            OracleDbType type;

            if (parameterType.IsDbType)
            {
                return(DbTypeToOracleDbType((DbType)parameterType.Code));
            }
            else if (TryGetOracleDbType(parameterType.Name, out type))
            {
                return(type);
            }
            throw new ArgumentException("Can not convert parameter to OracleParameter:" + parameterType);
        }
Exemplo n.º 3
0
        public static void AddOutputParam(SqlCommand cmd, string strName, DBParameterType paramType)
        {
            SqlParameter p = null;

            switch (paramType)
            {
            case DBParameterType.IntParamOutput:
                p = new SqlParameter(strName, SqlDbType.Int);
                break;

            case DBParameterType.StringParamOutput:
                p = new SqlParameter(strName, SqlDbType.VarChar, 8000);
                break;
            }


            p.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(p);
        }
Exemplo n.º 4
0
        private void AddDBParam(SqlCommand cmd, DBParameter dbParam)
        {
            if (dbParam.ParamValue == null)
            {
                AddDBParamNoValue(cmd, dbParam);
                return;
            }
            try
            {
                DBParameterType paramType = dbParam.ParamType;
                switch (paramType)
                {
                case DBParameterType.BoolParam:
                    SqlUtil.AddParam(cmd, dbParam.ParamName, (bool)dbParam.ParamValue); break;

                case DBParameterType.DateTimeParam:
                    SqlUtil.AddParam(cmd, dbParam.ParamName, (DateTime)dbParam.ParamValue); break;

                case DBParameterType.DoubleParam:
                    SqlUtil.AddParam(cmd, dbParam.ParamName, (double)dbParam.ParamValue); break;

                case DBParameterType.IntParam:
                    SqlUtil.AddParam(cmd, dbParam.ParamName, (int)dbParam.ParamValue); break;

                case DBParameterType.NullableIntParam:
                    SqlUtil.AddParam(cmd, dbParam.ParamName, (int?)dbParam.ParamValue); break;

                case DBParameterType.StringParam:
                    SqlUtil.AddParam(cmd, dbParam.ParamName, (string)dbParam.ParamValue); break;

                case DBParameterType.TextParam:
                    SqlUtil.AddParam(cmd, dbParam.ParamName, (string)dbParam.ParamValue, true); break;

                case DBParameterType.XmlParam:
                    SqlUtil.AddParam(cmd, dbParam.ParamName, (string)dbParam.ParamValue, false, true); break;

                case DBParameterType.BytesParam:
                    SqlUtil.AddParam(cmd, dbParam.ParamName, (byte[])dbParam.ParamValue); break;

                case DBParameterType.NcharParam:
                    SqlUtil.AddParam(cmd, dbParam.ParamName, dbParam.ParamValue == null ? new char[0] : ((string)dbParam.ParamValue).ToCharArray()); break;

                case DBParameterType.IntParamOutput:
                    SqlUtil.AddOutputParam(cmd, dbParam.ParamName, paramType);
                    ParameterNames.Add(dbParam.ParamName);
                    break;

                case DBParameterType.StringParamOutput:
                    SqlUtil.AddOutputParam(cmd, dbParam.ParamName, paramType);
                    ParameterNames.Add(dbParam.ParamName);
                    break;

                case DBParameterType.ByteParam:
                    SqlUtil.AddParam(cmd, dbParam.ParamName, (byte)dbParam.ParamValue); break;
                }
            }
#pragma warning disable 168
            catch (System.InvalidCastException whoops)
            {
                // bad data, treat as null...
                AddDBParamNoValue(cmd, dbParam);
            }
#pragma warning restore 168
        }