Exemplo n.º 1
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="parameterName">Parameter name</param>
		/// <param name="type">Parameter data type</param>
		/// <param name="sourceColumn">The name of the source column.</param>
		public VistaDBParameter(string parameterName, VistaDBType type, string sourceColumn)
		{
			this.paramName = parameterName;
			this.dbType = type;
			this.sourceColumn = sourceColumn;
			this.typeDefined = true;
		}
Exemplo n.º 2
0
 public override void SetParamNull(string pName, VistaDBType type)
 {
     lock (this)
     {
         this.parameterCollection.SetParameter(pName, type, null);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parameterName">Parameter name</param>
 /// <param name="type">Parameter data type</param>
 /// <param name="sourceColumn">The name of the source column.</param>
 public VistaDBParameter(string parameterName, VistaDBType type, string sourceColumn)
 {
     this.paramName    = parameterName;
     this.dbType       = type;
     this.sourceColumn = sourceColumn;
     this.typeDefined  = true;
 }
Exemplo n.º 4
0
 public override void SetParameter(string paramName, VistaDBType dataType, object value)
 {
     lock (this)
     {
         this.parameterCollection.SetParameter(paramName, dataType, value);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Set a V-SQL parameter value to NULL.
        /// </summary>
        public void SetParamNull(string pName, VistaDBType type)
        {
            if (queryID <= 0)
            {
                return;
            }

            VistaDBAPI.ivsql_SetParamNull(queryID, pName, (short)type);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Set a V-SQL parameter value to NULL.
        /// </summary>
        public override void SetParamNull(string pName, VistaDBType type)
        {
            if (this.queryID == 0)
            {
                return;
            }

            VistaDBAPI.ivsql_SetParamNull(queryID, pName, (short)type);
        }
Exemplo n.º 7
0
        private void Add(string name, VistaDBType dataType, object val)
        {
            int len = this.parameters != null ? this.parameters.Length : 0;

            RemoteParameter[] newParameters = new RemoteParameter[len + 1];

            if (this.parameters != null)
            {
                this.parameters.CopyTo(newParameters, 0);
            }

            newParameters[len] = new RemoteParameter(name, dataType, val);
            this.parameters    = newParameters;
        }
Exemplo n.º 8
0
        public void SetParameter(string name, VistaDBType dataType, object val)
        {
            if (this.parameters != null)
            {
                foreach (RemoteParameter p in this.parameters)
                {
                    if (p.Name == name)
                    {
                        p.DataType = dataType;
                        p.Value    = val;
                    }
                }
            }

            Add(name, dataType, val);
        }
Exemplo n.º 9
0
        static public Dictionary<string, VistaDBParameter> GetParameters(Guid dataID,
            tgProviderSpecificMetadata providerMetadata, tgColumnMetadataCollection columns)
        {
            lock (parameterCache)
            {
                if (!parameterCache.ContainsKey(dataID))
                {
                    // The Parameters for this Table haven't been cached yet, this is a one time operation
                    Dictionary<string, VistaDBParameter> types = new Dictionary<string, VistaDBParameter>();

                    VistaDBParameter param1;
                    foreach (tgColumnMetadata col in columns)
                    {
                        tgTypeMap typeMap = providerMetadata.GetTypeMap(col.PropertyName);
                        if (typeMap != null)
                        {
                            string nativeType = typeMap.NativeType;
                            VistaDBType dbType = Cache.NativeTypeToDbType(nativeType);

                            param1 = new VistaDBParameter(Delimiters.Param + col.PropertyName, dbType, 0, col.Name);
                            param1.SourceColumn = col.Name;

                            switch (dbType)
                            {
                                case VistaDBType.BigInt:
                                case VistaDBType.Int:
                                case VistaDBType.SmallInt:
                                case VistaDBType.Decimal:
                                case VistaDBType.Float:
                                case VistaDBType.Money:
                                case VistaDBType.SmallMoney:

                                    param1.Size = (int)col.CharacterMaxLength;
                                    break;

                            }
                            types[col.Name] = param1;
                        }
                    }

                    parameterCache[dataID] = types;
                }
            }

            return parameterCache[dataID];
        }
Exemplo n.º 10
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="parameterName">Parameter name.</param>
        /// <param name="dbType">VistaDBType type of the parameter.</param>
        /// <param name="size">maximum size, in bytes, of the data within the column.</param>
        /// <param name="direction">ParameterDirection.</param>
        /// <param name="isNullable">Indicates whether the parameter accepts null values.</param>
        /// <param name="precision">Maximum number of digits used to represent the Value property.</param>
        /// <param name="scale">Number of decimal places to which Value is resolved.</param>
        /// <param name="sourceColumn">Name of the source column that is mapped to the DataSet and used for loading or returning the Value.</param>
        /// <param name="sourceVersion">DataRowVersion to use when loading Value.</param>
        /// <param name="value">Value of the parameter.</param>
        public VistaDBParameter(string parameterName, VistaDBType dbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
        {
            this.dbType       = dbType;
            this.m_direction  = direction;
            this.nullable     = isNullable;
            this.paramName    = parameterName;
            this.sourceColumn = sourceColumn;

            this.m_sourceVersion = sourceVersion;

            this.val       = value;
            this.size      = size;
            this.scale     = scale;
            this.precision = precision;

            this.typeDefined = true;
        }
		internal VistaDBColumn(string _name, 
			VistaDBType _vistaDBType,
			int _dataSize,
			short _columnWidth,
			short _columnDecimals,
			bool _allowNull, 
			bool _readOnly, 
			bool _primaryKey,
			bool _unique,
			bool _identity,
			double _identityStep,
			string _identityValue,
			string _columnCaption,
			string _columnDescription,
			bool _reservedWord,
			bool _packed,
			bool _hidden,
			bool _encrypted,
			bool _unicode)
		{
			name = _name;
			vistaDBType = _vistaDBType;
			type = VistaDBAPI.GetFieldType(vistaDBType);
			dataSize = _dataSize;
			columnWidth = _columnWidth;
			columnDecimals = _columnDecimals;
			allowNull = _allowNull;
			readOnly = _readOnly;
			primaryKey = _primaryKey;
			unique = _unique;
			identity = _identity;
			identityStep = _identityStep;
			identityValue = _identityValue;
			columnCaption = _columnCaption;
			columnDescription = _columnDescription;
			reservedWord = _reservedWord;
			packed = _packed;
			hidden = _hidden;
			encrypted = _encrypted;
			unicode = _unicode;
		}
Exemplo n.º 12
0
 internal VistaDBColumn(string _name,
                        VistaDBType _vistaDBType,
                        int _dataSize,
                        short _columnWidth,
                        short _columnDecimals,
                        bool _allowNull,
                        bool _readOnly,
                        bool _primaryKey,
                        bool _unique,
                        bool _identity,
                        double _identityStep,
                        string _identityValue,
                        string _columnCaption,
                        string _columnDescription,
                        bool _reservedWord,
                        bool _packed,
                        bool _hidden,
                        bool _encrypted,
                        bool _unicode)
 {
     name              = _name;
     vistaDBType       = _vistaDBType;
     type              = VistaDBAPI.GetFieldType(vistaDBType);
     dataSize          = _dataSize;
     columnWidth       = _columnWidth;
     columnDecimals    = _columnDecimals;
     allowNull         = _allowNull;
     readOnly          = _readOnly;
     primaryKey        = _primaryKey;
     unique            = _unique;
     identity          = _identity;
     identityStep      = _identityStep;
     identityValue     = _identityValue;
     columnCaption     = _columnCaption;
     columnDescription = _columnDescription;
     reservedWord      = _reservedWord;
     packed            = _packed;
     hidden            = _hidden;
     encrypted         = _encrypted;
     unicode           = _unicode;
 }
Exemplo n.º 13
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="Name">Column name</param>
		/// <param name="DataType">Column data type</param>
		/// <param name="Length">Column data size</param>
		/// <param name="Decimals">Column decimals</param>
		/// <param name="Required">If True, then column required</param>
		/// <param name="ReadOnly">If True then column read only</param>
		/// <param name="Packed">If True then column packed</param>
		/// <param name="Hidden">If True then column hidden</param>
		/// <param name="Encrypted">If True then column encrypted</param>
		/// <param name="Unicode">Reserved, must be False</param>
		public VistaDBNewColumn(
			string Name, 
			VistaDBType DataType, 
			int Length,
			short Decimals,
			bool Required,
			bool ReadOnly,
			bool Packed,
			bool Hidden,
			bool Encrypted,
			bool Unicode
			)
		{
			name = Name;
			type = DataType; 
			length = Length;
			decimals = Decimals;
			required = Required;
			readOnly = ReadOnly;
			packed = Packed;
			hidden = Hidden;
			encrypted = Encrypted;
			unicode = Unicode;
		}
Exemplo n.º 14
0
 public RemoteParameter(string name, VistaDBType type, object val)
 {
     this.type = type;
     this.name = name;
     this.val  = val;
 }
Exemplo n.º 15
0
		public static string NativeDataType(VistaDBType t)
		{
			return vdbTypes[(int)t];
		}
Exemplo n.º 16
0
        ////////////////////////////////////////////////////////////
        ////////////////Data and parameter functions////////////////
        ////////////////////////////////////////////////////////////

        /// <summary>
        /// Set a V-SQL parameter.
        /// </summary>
        /// <param name="paramName">Parameter name.</param>
        /// <param name="dataType">Parameter data type.</param>
        /// <param name="value">Data value</param>
        public void SetParameter(string paramName, VistaDBType dataType, object value)
        {
            //Set parameter value
            //Depending on 'dataType' this function call different
            //API SQL functions for this 'dataType'
            //If 'value' is null then set parameter to null value
            long tickCount;

            if (queryID <= 0)
            {
                return;
            }

            switch (dataType)
            {
            case VistaDBType.Character:
                VistaDBAPI.ivsql_SetParamString(queryID, paramName, (string)value);
                break;

            case VistaDBType.Date:
                tickCount = ((DateTime)value).Ticks;
                VistaDBAPI.ivsql_SetParamDate(queryID, paramName, (long)tickCount);
                break;

            case VistaDBType.DateTime:
                tickCount = ((DateTime)value).Ticks;
                VistaDBAPI.ivsql_SetParamDateTime(queryID, paramName, (long)tickCount);
                break;

            case VistaDBType.Boolean:
                VistaDBAPI.ivsql_SetParamBoolean(queryID, paramName, (bool)value);
                break;

            case VistaDBType.Memo:
                VistaDBAPI.ivsql_SetParamMemo(queryID, paramName, (string)value);
                break;

            case VistaDBType.Picture:
                VistaDBAPI.ivsql_SetParamBlob(queryID, paramName, (byte[])value, ((byte[])value).Length);
                break;

            case VistaDBType.Blob:
                VistaDBAPI.ivsql_SetParamBlob(queryID, paramName, (byte[])value, ((byte[])value).Length);
                break;

            case VistaDBType.Currency:

                decimal dVal = (decimal)value;
                long    longValue;
                longValue = (long)(dVal * 10000);

                VistaDBAPI.ivsql_SetParamCurrency(queryID, paramName, longValue);
                break;

            case VistaDBType.Int32:
                VistaDBAPI.ivsql_SetParamInt32(queryID, paramName, (int)value);
                break;

            case VistaDBType.Int64:
                VistaDBAPI.ivsql_SetParamInt64(queryID, paramName, (long)value);
                break;

            case VistaDBType.Double:
                VistaDBAPI.ivsql_SetParamDouble(queryID, paramName, (double)value);
                break;

            case VistaDBType.Varchar:
                VistaDBAPI.ivsql_SetParamVarchar(queryID, paramName, (string)value);
                break;

            case VistaDBType.Guid:
                VistaDBAPI.ivsql_SetParamGuid(queryID, paramName, (Guid)value);
                break;
            }
        }
		private void Add(string name, VistaDBType dataType, object val)
		{
			int len = this.parameters != null ? this.parameters.Length : 0;
			RemoteParameter[] newParameters = new RemoteParameter[len + 1];

			if(this.parameters != null)
				this.parameters.CopyTo(newParameters, 0);

			newParameters[len] = new RemoteParameter(name, dataType, val);
			this.parameters = newParameters;
		}
		/// <summary>
		/// Adds a VistaDBParameter to the VistaDBParameterCollection with the parameter name, the data type, and the source column name.
		/// </summary>
		/// <param name="parameterName">The name of the parameter. </param>
		/// <param name="dbType">One of the VistaDBType values. </param>
		/// <param name="sourceColumn">The name of the source column. </param>
		/// <returns>The index of the new VistaDBParameter object.</returns>
		public VistaDBParameter Add(string parameterName, VistaDBType dbType, string sourceColumn)
		{
			return Add(new VistaDBParameter(parameterName, dbType, sourceColumn));
		}
Exemplo n.º 19
0
 /// <summary>
 /// Adds a VistaDBParameter to the VistaDBParameterCollection with the parameter name, the data type, and the source column name.
 /// </summary>
 /// <param name="parameterName">The name of the parameter. </param>
 /// <param name="dbType">One of the VistaDBType values. </param>
 /// <param name="sourceColumn">The name of the source column. </param>
 /// <returns>The index of the new VistaDBParameter object.</returns>
 public VistaDBParameter Add(string parameterName, VistaDBType dbType, string sourceColumn)
 {
     return(Add(new VistaDBParameter(parameterName, dbType, sourceColumn)));
 }
Exemplo n.º 20
0
		private DbType VistaDBTypeToDbType(VistaDBType type)
		{
			return vdbTypes[(int)type];
		}
		////////////////////////////////////////////////////////////
		////////////////Data and parameter functions////////////////
		////////////////////////////////////////////////////////////

		/// <summary>
		/// Set a V-SQL parameter.
		/// </summary>
		/// <param name="paramName">Parameter name.</param>
		/// <param name="dataType">Parameter data type.</param>
		/// <param name="value">Data value</param>
		public abstract void SetParameter(string paramName, VistaDBType dataType, object value);
		/// <summary>
		/// Set a V-SQL parameter value to NULL.
		/// </summary>
		public abstract void SetParamNull(string pName, VistaDBType type);
Exemplo n.º 23
0
		/// <summary>
		/// Set a V-SQL parameter value to NULL.
		/// </summary>
		public override void SetParamNull(string pName, VistaDBType type)
		{
			if( this.queryID == 0 )
				return;

			VistaDBAPI.ivsql_SetParamNull(queryID, pName, (short)type);
		}
Exemplo n.º 24
0
		public override void SetParameter(string paramName, VistaDBType dataType, object value)
		{
			lock(this)
			{
				this.parameterCollection.SetParameter(paramName, dataType, value);
			}
		}
Exemplo n.º 25
0
		/// <summary>
		/// Set a V-SQL parameter.
		/// </summary>
		/// <param name="paramName">Parameter name.</param>
		/// <param name="dataType">Parameter data type.</param>
		/// <param name="value">Data value</param>
		public override void SetParameter(string paramName, VistaDBType dataType, object value)
		{
			//Set parameter value
			//Depending on 'dataType' this function call different
			//API SQL functions for this 'dataType'
			//If 'value' is null then set parameter to null value
			long tickCount;

			if( this.queryID == 0 )
				return;

			switch(dataType)
			{
				case VistaDBType.Character:
					VistaDBAPI.ivsql_SetParamString(this.queryID, paramName, (string)value);
					break;
				case VistaDBType.Date:
					tickCount = ((DateTime)value).Ticks;
					VistaDBAPI.ivsql_SetParamDate(this.queryID, paramName, (long)tickCount);
					break;
				case VistaDBType.DateTime:
					tickCount = ((DateTime)value).Ticks;
					VistaDBAPI.ivsql_SetParamDateTime(this.queryID, paramName, (long)tickCount);
					break;
				case VistaDBType.Boolean:
					VistaDBAPI.ivsql_SetParamBoolean(this.queryID, paramName, (bool)value);
					break;
				case VistaDBType.Memo:
					VistaDBAPI.ivsql_SetParamMemo(this.queryID, paramName, (string)value);
					break;
				case VistaDBType.Picture:
					VistaDBAPI.ivsql_SetParamBlob(this.queryID, paramName, (byte[])value, ((byte[])value).Length ); 
					break;
				case VistaDBType.Blob:
					VistaDBAPI.ivsql_SetParamBlob(this.queryID, paramName, (byte[])value, ((byte[])value).Length ); 
					break;
				case VistaDBType.Currency:

					decimal dVal = (decimal)value;
					long longValue;
					longValue = (long)(dVal * 10000);

					VistaDBAPI.ivsql_SetParamCurrency(this.queryID, paramName, longValue);
					break;
				case VistaDBType.Int32:
					VistaDBAPI.ivsql_SetParamInt32(this.queryID, paramName, (int)value);
					break;
				case VistaDBType.Int64:
					VistaDBAPI.ivsql_SetParamInt64(this.queryID, paramName, (long)value);
					break;
				case VistaDBType.Double:
					VistaDBAPI.ivsql_SetParamDouble(this.queryID, paramName, (double)value);
					break;
				case VistaDBType.Varchar:
					VistaDBAPI.ivsql_SetParamVarchar(this.queryID, paramName, (string)value);
					break;
				case VistaDBType.Guid:
					VistaDBAPI.ivsql_SetParamGuid(this.queryID, paramName, (Guid)value);
					break;
			}		
		}
Exemplo n.º 26
0
 /// <summary>
 /// Set a V-SQL parameter value to NULL.
 /// </summary>
 public abstract void SetParamNull(string pName, VistaDBType type);
Exemplo n.º 27
0
        ////////////////////////////////////////////////////////////
        ////////////////Data and parameter functions////////////////
        ////////////////////////////////////////////////////////////

        /// <summary>
        /// Set a V-SQL parameter.
        /// </summary>
        /// <param name="paramName">Parameter name.</param>
        /// <param name="dataType">Parameter data type.</param>
        /// <param name="value">Data value</param>
        public abstract void SetParameter(string paramName, VistaDBType dataType, object value);
		/// <summary>
		/// Set a V-SQL parameter value to NULL.
		/// </summary>
		public void SetParamNull(string pName, VistaDBType type)
		{
			if( queryID <= 0 )
				return;

			VistaDBAPI.ivsql_SetParamNull(queryID, pName, (short)type);
		}
Exemplo n.º 29
0
			internal VistaDBPropertyDescriptor(string name, Type propertyType, int columnNo, VistaDBType dataType, bool readOnly): base(name, null)
			{
				this.propertyType = propertyType;
				this.columnNo     = columnNo;
				this.dataType     = dataType;
				this.readOnly     = readOnly;
			}
Exemplo n.º 30
0
 /// <summary>
 /// Adds a VistaDBParameter to the VistaDBParameterCollection given the specified parameter name and type.
 /// </summary>
 /// <param name="parameterName">The name of the VistaDBParameter parameter.</param>
 /// <param name="type"></param>
 /// <returns></returns>
 public VistaDBParameter Add(string parameterName, VistaDBType type)
 {
     return(Add(new VistaDBParameter(parameterName, type)));
 }
Exemplo n.º 31
0
 public VistaDBColumn(string actualName, Table table, bool isIdentity, VistaDBType vistaDbType, int maxLength)
     : base(actualName, table, isIdentity, default(DbType), maxLength)
 {
     _vistaDbType = vistaDbType;
 }
Exemplo n.º 32
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="parameterName">Parameter name.</param>
		/// <param name="dbType">VistaDBType type of the parameter.</param>
		/// <param name="size">maximum size, in bytes, of the data within the column.</param>
		/// <param name="direction">ParameterDirection.</param>
		/// <param name="isNullable">Indicates whether the parameter accepts null values.</param>
		/// <param name="precision">Maximum number of digits used to represent the Value property.</param>
		/// <param name="scale">Number of decimal places to which Value is resolved.</param>
		/// <param name="sourceColumn">Name of the source column that is mapped to the DataSet and used for loading or returning the Value.</param>
		/// <param name="sourceVersion">DataRowVersion to use when loading Value.</param>
		/// <param name="value">Value of the parameter.</param>
		public VistaDBParameter(string parameterName, VistaDBType dbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
		{
			this.dbType = dbType;
			this.m_direction = direction;
			this.nullable = isNullable;
			this.paramName = parameterName;
			this.sourceColumn = sourceColumn;

			this.m_sourceVersion = sourceVersion;
			
			this.val = value;
			this.size = size;
			this.scale = scale;
			this.precision = precision;

			this.typeDefined = true;
		}
Exemplo n.º 33
0
		/// <summary>
		/// Defines a column to be included in a new table. A new table is created by first making a table ID with CreateNew. Each column is then defined with CreateColumn, and the table is finally physically created by calling CreateFinalize.
		/// </summary>
		/// <param name="sName">Column name</param>
		/// <param name="vdbType">Column data type</param>
		/// <param name="iLength">Length for column</param>
		/// <param name="iDecimals">Decimals for column</param>
		public void CreateColumn(string sName, VistaDBType vdbType, short iLength, short iDecimals)
		{
			if( tableId >= 0 )
			{
				throw new VistaDBException(VistaDBErrorCodes.TableNotInCreateMode);
			}

			string sType = VistaDBAPI.NativeDataType(vdbType);

			lock(database.SyncRoot)
			{
				ConnectDatabase();
				VistaDBAPI.ivdb_CreateColumn(sName, sType, iLength, iDecimals, false, false, false, false, false, false);
			}
		}
Exemplo n.º 34
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="parameterName">Parameter name</param>
		/// <param name="type">Parameter data type</param>
		public VistaDBParameter(string parameterName, VistaDBType type)
		{
			this.paramName = parameterName;
			this.dbType = type;
			this.typeDefined = true;
		}
Exemplo n.º 35
0
		/// <summary>
		///  Defines a column with extended options to be included in a new table. A new table is created by first making a table ID with CreateNew. Each column is then defined with CreateColumn, and the table is finally physically created by calling CreateFinalize.
		/// </summary>
		/// <param name="sName">Column name</param>
		/// <param name="vdbType">Column data type</param>
		/// <param name="iLength">Length for column</param>
		/// <param name="iDecimals">Decimals for column</param>
		/// <param name="bRequired">True for required</param>
		/// <param name="bReadOnly">True for read only</param>
		/// <param name="bPacked">True for packed</param>
		/// <param name="bHidden">True for hidden</param>
		/// <param name="bEncrypted">True for encrypted</param>
		/// <param name="bUnicode">This is parameter reserved</param>
		public void CreateColumn(string sName, VistaDBType vdbType, int iLength, short iDecimals,
			bool bRequired, bool bReadOnly, bool bPacked, bool bHidden, bool bEncrypted, bool bUnicode)
		{
			if(tableId >= 0)
			{
				throw new VistaDBException(VistaDBErrorCodes.TableNotInCreateMode);
			}

			string sType = VistaDBAPI.NativeDataType(vdbType);

			lock(database.SyncRoot)
			{
				ConnectDatabase();
				VistaDBAPI.ivdb_CreateColumn(sName, sType, iLength, iDecimals,
					bRequired, bReadOnly, bPacked, bHidden, bEncrypted, bUnicode);
			}
		}
		/// <summary>
		/// Adds a VistaDBParameter to the VistaDBParameterCollection given the specified parameter name and type.
		/// </summary>
		/// <param name="parameterName">The name of the VistaDBParameter parameter.</param>
		/// <param name="type"></param>
		/// <returns></returns>
		public VistaDBParameter Add(string parameterName, VistaDBType type)
		{
			return Add(new VistaDBParameter(parameterName, type));
		}
		public int PutParameterToBuffer(byte[] buffer, int offset, bool getSize)
		{
			int           size     = 0;
			string        s;
			Encoding encoding = Encoding.Default;

			if(this.val == null)
			{
				ushort type = 0;

				switch(this.type)
				{
					case VistaDBType.Character:
					case VistaDBType.Varchar:
					case VistaDBType.Memo:
						type = (ushort)ServerNativeType.Character;
						break;
					case VistaDBType.Date:
						type = (ushort)ServerNativeType.Date;
						break;
					case VistaDBType.DateTime:
						type = (ushort)ServerNativeType.DateTime;
						break;
					case VistaDBType.Boolean:
						type = (ushort)ServerNativeType.Boolean;
						break;
					case VistaDBType.Picture:
					case VistaDBType.Blob:
						type = (ushort)ServerNativeType.Blob;
						break;
					case VistaDBType.Currency:
						type = (ushort)ServerNativeType.Currency;
						break;
					case VistaDBType.Int32:
						type= (ushort)ServerNativeType.Int32;
						break;
					case VistaDBType.Int64:
						type = (ushort)ServerNativeType.Int64;
						break;
					case VistaDBType.Double:
						type = (ushort)ServerNativeType.Double;
						break;
					case VistaDBType.Guid:
						type = (ushort)ServerNativeType.Guid;
						break;
				}

				if(!getSize)
				{
					offset = PutParamInfo(buffer, offset, 0, type, encoding);
				}
			}
			else
			{
				switch(this.type)
				{
					case VistaDBType.Character:
					case VistaDBType.Varchar:
					case VistaDBType.Memo:
						s = (string)this.val;
						size = s.Length + 1;
						if(!getSize)
						{
							offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Character, encoding);
							encoding.GetBytes(s).CopyTo(buffer, offset);
							buffer[offset + s.Length] = 0;
						}
						break;
					case VistaDBType.Date:
						size = 4;
						if(!getSize)
						{
							long timeStamp = ((DateTime)this.val).Ticks / 10000 + 86400000;
							int  date      = (int)(timeStamp / VistaDBAPI.MSecsPerDay);
							offset         = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Date, encoding);
							BitConverter.GetBytes(date).CopyTo(buffer, offset);
						}
						break;
					case VistaDBType.DateTime:
						size = 8;
						if(!getSize)
						{
							double dateTime  = ((DateTime)this.val).Ticks / 10000;
							offset          = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.DateTime, encoding);
							BitConverter.GetBytes(dateTime).CopyTo(buffer, offset);
						}
						break;
					case VistaDBType.Boolean:
						size = 2;
						if(!getSize)
						{
							ushort b = (bool)this.val ? (ushort)1: (ushort)0;
							offset   = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Boolean, encoding);
							BitConverter.GetBytes(b).CopyTo(buffer, offset);
						}
						break;
					case VistaDBType.Picture:
					case VistaDBType.Blob:
						size = ((byte[])this.val).Length;
						if(!getSize)
						{
							offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Blob, encoding);
							((byte[])val).CopyTo(buffer, offset);
						}
						break;
					case VistaDBType.Currency:
						size = 34;
						if(!getSize)
						{
							offset    = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Currency, encoding);
							CurrToBcd(buffer, offset);
						}
						break;
					case VistaDBType.Int32:
						size = 4;
						if(!getSize)
						{
							offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Int32, encoding);
							BitConverter.GetBytes((int)this.val).CopyTo(buffer, offset);
						}
						break;
					case VistaDBType.Int64:
						size = 8;
						if(!getSize)
						{
							offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Int64, encoding);
							BitConverter.GetBytes((long)this.val).CopyTo(buffer, offset);
						}
						break;
					case VistaDBType.Double:
						size = 8;
						if(!getSize)
						{
							offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Double, encoding);
							BitConverter.GetBytes((double)this.val).CopyTo(buffer, offset);
						}
						break;
					case VistaDBType.Guid:
						s = "{" + this.val.ToString() + "}";
						size     = s.Length + 1;
						if(!getSize)
						{
							offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Guid, encoding);
							encoding.GetBytes(s).CopyTo(buffer, offset);
							buffer[offset + s.Length] = 0;
						}
						break;
				}
			}

			size += 8 + 2 + 2 + 20;
			return size;
		}
Exemplo n.º 38
0
		public static Type GetFieldType(VistaDBType colType) 
		{
			switch (colType) 
			{
				case VistaDBType.Character:		return typeof(System.String);
				case VistaDBType.Varchar:		return typeof(System.String);
				case VistaDBType.Memo:		    return typeof(System.String);

				case VistaDBType.Date:
				case VistaDBType.DateTime: 		return typeof(System.DateTime);

				case VistaDBType.Double:		return typeof(System.Double);
				case VistaDBType.Int32:			return typeof(System.Int32);
				case VistaDBType.Int64:			return typeof(System.Int64);

				case VistaDBType.Currency:		return typeof(System.Decimal);

				case VistaDBType.Boolean:	    return typeof(System.Boolean);

				case VistaDBType.Picture:
				case VistaDBType.Blob:		    return typeof(System.Array);

				case VistaDBType.Guid:			return typeof(System.Guid);

				default:
					return typeof(System.String);
			}
		}
Exemplo n.º 39
0
 private DbType VistaDBTypeToDbType(VistaDBType type)
 {
     return(vdbTypes[(int)type]);
 }
		public RemoteParameter(string name, VistaDBType type, object val)
		{
			this.type = type;
			this.name = name;
			this.val  = val;
		}
Exemplo n.º 41
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parameterName">Parameter name</param>
 /// <param name="type">Parameter data type</param>
 public VistaDBParameter(string parameterName, VistaDBType type)
 {
     this.paramName   = parameterName;
     this.dbType      = type;
     this.typeDefined = true;
 }
Exemplo n.º 42
0
 internal VistaDBPropertyDescriptor(string name, Type propertyType, int columnNo, VistaDBType dataType, bool readOnly) : base(name, null)
 {
     this.propertyType = propertyType;
     this.columnNo     = columnNo;
     this.dataType     = dataType;
     this.readOnly     = readOnly;
 }
		public void SetParameter(string name, VistaDBType dataType, object val)
		{
			if(this.parameters != null)
			{
				foreach(RemoteParameter p in this.parameters)
					if(p.Name == name)
					{
						p.DataType = dataType;
						p.Value = val;
					}
			}

			Add(name, dataType, val);
		}
Exemplo n.º 44
0
		/// <summary>
		/// Alter the column
		/// </summary>
		/// <param name="sOldColumnName">Old column name</param>
		/// <param name="sNewColumnName">New column name</param>
		/// <param name="vdbType">Column data type</param>
		/// <param name="iLength">Column data length</param>
		/// <param name="iDecimals">Column data decimals</param>
		/// <param name="bRequired">Column required attribute</param>
		/// <param name="bReadOnly">Column read only attribute</param>
		/// <param name="bPacked">Column packed attribute</param>
		/// <param name="bHidden">Column hidden attribute</param>
		/// <param name="bEncrypted">Column encrypted attribute</param>
		/// <param name="bUnicode">Reserved</param>
		/// <returns>True for success</returns>
		public bool AlterColumn( string sOldColumnName, string sNewColumnName, VistaDBType vdbType, int iLength, short iDecimals, bool bRequired, bool bReadOnly, bool bPacked, bool bHidden, bool bEncrypted, bool bUnicode)
		{
			string sType = VistaDBAPI.NativeDataType(vdbType);

			lock(database.SyncRoot)
			{
				ConnectDatabase();
				return VistaDBAPI.ivdb_AlterColumn(sOldColumnName, sNewColumnName, sType, iLength, iDecimals, bRequired, bReadOnly, bPacked, bHidden, bEncrypted, bUnicode);
			}
		}
Exemplo n.º 45
0
		public override void SetParamNull(string pName, VistaDBType type)
		{
			lock(this)
			{
				this.parameterCollection.SetParameter(pName, type, null);
			}
		}
Exemplo n.º 46
0
        public int PutParameterToBuffer(byte[] buffer, int offset, bool getSize)
        {
            int      size = 0;
            string   s;
            Encoding encoding = Encoding.Default;

            if (this.val == null)
            {
                ushort type = 0;

                switch (this.type)
                {
                case VistaDBType.Character:
                case VistaDBType.Varchar:
                case VistaDBType.Memo:
                    type = (ushort)ServerNativeType.Character;
                    break;

                case VistaDBType.Date:
                    type = (ushort)ServerNativeType.Date;
                    break;

                case VistaDBType.DateTime:
                    type = (ushort)ServerNativeType.DateTime;
                    break;

                case VistaDBType.Boolean:
                    type = (ushort)ServerNativeType.Boolean;
                    break;

                case VistaDBType.Picture:
                case VistaDBType.Blob:
                    type = (ushort)ServerNativeType.Blob;
                    break;

                case VistaDBType.Currency:
                    type = (ushort)ServerNativeType.Currency;
                    break;

                case VistaDBType.Int32:
                    type = (ushort)ServerNativeType.Int32;
                    break;

                case VistaDBType.Int64:
                    type = (ushort)ServerNativeType.Int64;
                    break;

                case VistaDBType.Double:
                    type = (ushort)ServerNativeType.Double;
                    break;

                case VistaDBType.Guid:
                    type = (ushort)ServerNativeType.Guid;
                    break;
                }

                if (!getSize)
                {
                    offset = PutParamInfo(buffer, offset, 0, type, encoding);
                }
            }
            else
            {
                switch (this.type)
                {
                case VistaDBType.Character:
                case VistaDBType.Varchar:
                case VistaDBType.Memo:
                    s    = (string)this.val;
                    size = s.Length + 1;
                    if (!getSize)
                    {
                        offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Character, encoding);
                        encoding.GetBytes(s).CopyTo(buffer, offset);
                        buffer[offset + s.Length] = 0;
                    }
                    break;

                case VistaDBType.Date:
                    size = 4;
                    if (!getSize)
                    {
                        long timeStamp = ((DateTime)this.val).Ticks / 10000 + 86400000;
                        int  date      = (int)(timeStamp / VistaDBAPI.MSecsPerDay);
                        offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Date, encoding);
                        BitConverter.GetBytes(date).CopyTo(buffer, offset);
                    }
                    break;

                case VistaDBType.DateTime:
                    size = 8;
                    if (!getSize)
                    {
                        double dateTime = ((DateTime)this.val).Ticks / 10000;
                        offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.DateTime, encoding);
                        BitConverter.GetBytes(dateTime).CopyTo(buffer, offset);
                    }
                    break;

                case VistaDBType.Boolean:
                    size = 2;
                    if (!getSize)
                    {
                        ushort b = (bool)this.val ? (ushort)1: (ushort)0;
                        offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Boolean, encoding);
                        BitConverter.GetBytes(b).CopyTo(buffer, offset);
                    }
                    break;

                case VistaDBType.Picture:
                case VistaDBType.Blob:
                    size = ((byte[])this.val).Length;
                    if (!getSize)
                    {
                        offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Blob, encoding);
                        ((byte[])val).CopyTo(buffer, offset);
                    }
                    break;

                case VistaDBType.Currency:
                    size = 34;
                    if (!getSize)
                    {
                        offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Currency, encoding);
                        CurrToBcd(buffer, offset);
                    }
                    break;

                case VistaDBType.Int32:
                    size = 4;
                    if (!getSize)
                    {
                        offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Int32, encoding);
                        BitConverter.GetBytes((int)this.val).CopyTo(buffer, offset);
                    }
                    break;

                case VistaDBType.Int64:
                    size = 8;
                    if (!getSize)
                    {
                        offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Int64, encoding);
                        BitConverter.GetBytes((long)this.val).CopyTo(buffer, offset);
                    }
                    break;

                case VistaDBType.Double:
                    size = 8;
                    if (!getSize)
                    {
                        offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Double, encoding);
                        BitConverter.GetBytes((double)this.val).CopyTo(buffer, offset);
                    }
                    break;

                case VistaDBType.Guid:
                    s    = "{" + this.val.ToString() + "}";
                    size = s.Length + 1;
                    if (!getSize)
                    {
                        offset = PutParamInfo(buffer, offset, size, (ushort)ServerNativeType.Guid, encoding);
                        encoding.GetBytes(s).CopyTo(buffer, offset);
                        buffer[offset + s.Length] = 0;
                    }
                    break;
                }
            }

            size += 8 + 2 + 2 + 20;
            return(size);
        }
Exemplo n.º 47
0
 public VistaDBColumn(string actualName, Table table, VistaDBType vistaDbType)
     : base(actualName, table)
 {
     _vistaDbType = vistaDbType;
 }