Example #1
0
        public VistaDBMetaDataReader EnumTables()
        {
            if (!this.opened)
            {
                throw new VistaDBException(VistaDBErrorCodes.ConnectionNotOpened);
            }

            int errorCode;

            byte[] answer;
            byte[] buffer;
            VistaDBMetaDataReader metaDataReader;
            ASCIIEncoding         encoding = new ASCIIEncoding();

            //Send request
            SendMessage(ActionList.sc_SRV_ENUMTABLES, this.database);

            //Receive answer
            ReceiveMessage(out answer);

            //Get error code
            errorCode = Int32.Parse(encoding.GetString(answer, 0, 4), NumberStyles.AllowHexSpecifier);

            //Check if here occurred error then raise exception
            if (errorCode != 0)
            {
                //Get error message
                string message = encoding.GetString(answer, 4, answer.Length - 4);
                throw new VistaDBException(message, VistaDBErrorCodes.ServerError);
            }

            //Prepare meta data reader
            buffer = new byte[answer.Length - 4];
            Array.Copy(answer, 4, buffer, 0, buffer.Length);
            metaDataReader = new VistaDBMetaDataReader(buffer);

            return(metaDataReader);
        }
		public VistaDBMetaDataReader EnumTables()
		{
			if(!this.opened)
				throw new VistaDBException(VistaDBErrorCodes.ConnectionNotOpened);

			int errorCode;
			byte[] answer;
			byte[] buffer;
			VistaDBMetaDataReader metaDataReader;
			ASCIIEncoding encoding = new ASCIIEncoding();

			//Send request
			SendMessage(ActionList.sc_SRV_ENUMTABLES, this.database);

			//Receive answer
			ReceiveMessage(out answer);
		
			//Get error code
			errorCode = Int32.Parse(encoding.GetString(answer, 0, 4), NumberStyles.AllowHexSpecifier);

			//Check if here occurred error then raise exception
			if(errorCode != 0)
			{
				//Get error message
				string message         = encoding.GetString(answer, 4, answer.Length - 4);
				throw new VistaDBException(message, VistaDBErrorCodes.ServerError);
			}

			//Prepare meta data reader
			buffer = new byte[answer.Length - 4];
			Array.Copy(answer, 4, buffer, 0, buffer.Length);
			metaDataReader = new VistaDBMetaDataReader(buffer);

			return metaDataReader;
		}