Beispiel #1
0
        static public object ConvertByOleDbType(object v, OleDbType oleDbType)
        {
            if (v == null || v == DBNull.Value)
            {
                return(DBNull.Value);
            }
            switch (oleDbType)
            {
            case System.Data.OleDb.OleDbType.BigInt:
                return(ToLong(v));

            case System.Data.OleDb.OleDbType.Binary:
                return(ToBytes(v));

            case System.Data.OleDb.OleDbType.Boolean:
                return(ToBool(v));

            case System.Data.OleDb.OleDbType.BSTR:
                return(ToString(v));

            case System.Data.OleDb.OleDbType.Char:
                return(ToChar(v));

            case System.Data.OleDb.OleDbType.Currency:
                return(ToDecimal(v));

            case System.Data.OleDb.OleDbType.Date:
                return(ToDateTime(v));

            case System.Data.OleDb.OleDbType.DBDate:
                return(ToDateTime(v));

            case System.Data.OleDb.OleDbType.DBTime:
                return(ToTime(v));

            case System.Data.OleDb.OleDbType.DBTimeStamp:
                return(ToDateTime(v));

            case System.Data.OleDb.OleDbType.Decimal:
                return(ToDecimal(v));

            case System.Data.OleDb.OleDbType.Double:
                return(ToDouble(v));

            case System.Data.OleDb.OleDbType.Empty:
                return(EPField.DefaultFieldValue(oleDbType));

            case System.Data.OleDb.OleDbType.Filetime:
                return(ToDateTime(v));

            case System.Data.OleDb.OleDbType.Guid:
                return(ToGuid(v));

            case System.Data.OleDb.OleDbType.IDispatch:
                return(v);

            case System.Data.OleDb.OleDbType.Integer:
                return(ToInt(v));

            case System.Data.OleDb.OleDbType.IUnknown:
                return(v);

            case System.Data.OleDb.OleDbType.LongVarBinary:
                return(ToBytes(v));

            case System.Data.OleDb.OleDbType.LongVarChar:
                return(ToString(v));

            case System.Data.OleDb.OleDbType.LongVarWChar:
                return(ToString(v));

            case System.Data.OleDb.OleDbType.Numeric:
                return(ToDecimal(v));

            case System.Data.OleDb.OleDbType.PropVariant:
                return(v);

            case System.Data.OleDb.OleDbType.Single:
                return(ToFloat(v));

            case System.Data.OleDb.OleDbType.SmallInt:
                return(ToInt16(v));

            case System.Data.OleDb.OleDbType.TinyInt:
                return(ToSByte(v));

            case System.Data.OleDb.OleDbType.UnsignedBigInt:
                return(ToU64(v));

            case System.Data.OleDb.OleDbType.UnsignedInt:
                return(ToU32(v));

            case System.Data.OleDb.OleDbType.UnsignedSmallInt:
                return(ToU16(v));

            case System.Data.OleDb.OleDbType.UnsignedTinyInt:
                return(ToByte(v));

            case System.Data.OleDb.OleDbType.VarBinary:
                return(ToBytes(v));

            case System.Data.OleDb.OleDbType.VarChar:
                return(ToString(v));

            case System.Data.OleDb.OleDbType.Variant:
                return(v);

            case System.Data.OleDb.OleDbType.VarNumeric:
                return(ToDecimal(v));

            case System.Data.OleDb.OleDbType.VarWChar:
                return(ToString(v));

            case System.Data.OleDb.OleDbType.WChar:
                return(ToString(v));

            default:
                return(ToString(v));
            }
        }