GetColumns() public method

public GetColumns ( int count ) : MySql.Data.MySqlClient.MySqlField[]
count int
return MySql.Data.MySqlClient.MySqlField[]
Esempio n. 1
0
        public int PrepareStatement(string sql, ref MySqlField[] parameters)
        {
            //TODO: check this
            //ClearFetchedRow();

            packet.Length = sql.Length * 4 + 5;
            byte[] buffer = packet.Buffer;
            int    len    = Encoding.GetBytes(sql, 0, sql.Length, packet.Buffer, 5);

            packet.Position = len + 5;
            buffer[4]       = (byte)DBCmd.PREPARE;
            ExecutePacket(packet);

            packet = stream.ReadPacket();

            int marker = packet.ReadByte();

            if (marker != 0)
            {
                throw new MySqlException("Expected prepared statement marker");
            }

            int statementId = packet.ReadInteger(4);
            int numCols     = packet.ReadInteger(2);
            int numParams   = packet.ReadInteger(2);

            //TODO: find out what this is needed for
            packet.ReadInteger(3);
            if (numParams > 0)
            {
                parameters = owner.GetColumns(numParams);
                // we set the encoding for each parameter back to our connection encoding
                // since we can't trust what is coming back from the server
                for (int i = 0; i < parameters.Length; i++)
                {
                    parameters[i].Encoding = Encoding;
                }
            }

            if (numCols > 0)
            {
                while (numCols-- > 0)
                {
                    packet = stream.ReadPacket();
                    //TODO: handle streaming packets
                }

                ReadEOF();
            }

            return(statementId);
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the column metadata for the current resultset
        /// </summary>
        private void LoadColumns(int numCols)
        {
            Fields = _driver.GetColumns(numCols);

            Values        = new IMySqlValue[numCols];
            _uaFieldsUsed = new bool[numCols];
            _fieldHashCi  = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase);

            for (int i = 0; i < Fields.Length; i++)
            {
                string columnName = Fields[i].ColumnName;
                if (!_fieldHashCi.ContainsKey(columnName))
                {
                    _fieldHashCi.Add(columnName, i);
                }
                Values[i] = Fields[i].GetValueObject();
            }
        }
        /// <summary>
        /// Loads the column metadata for the current resultset
        /// </summary>
        private void LoadColumns(int numCols)
        {
            fields = driver.GetColumns(numCols);

            values       = new IMySqlValue[numCols];
            uaFieldsUsed = new bool[numCols];
            fieldHashCS  = new Hashtable();
            fieldHashCI  = new Hashtable(StringComparer.InvariantCultureIgnoreCase);

            for (int i = 0; i < fields.Length; i++)
            {
                string columnName = fields[i].ColumnName;
                if (!fieldHashCS.ContainsKey(columnName))
                {
                    fieldHashCS.Add(columnName, i);
                }
                if (!fieldHashCI.ContainsKey(columnName))
                {
                    fieldHashCI.Add(columnName, i);
                }
                values[i] = fields[i].GetValueObject();
            }
        }