當前位置: 首頁>>代碼示例>>C#>>正文


C# MySqlClient.MySqlField類代碼示例

本文整理匯總了C#中MySql.Data.MySqlClient.MySqlField的典型用法代碼示例。如果您正苦於以下問題:C# MySqlField類的具體用法?C# MySqlField怎麽用?C# MySqlField使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MySqlField類屬於MySql.Data.MySqlClient命名空間,在下文中一共展示了MySqlField類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetColumnData

    private void GetColumnData(MySqlField field)
    {
      stream.Encoding = Encoding;
      packet = stream.ReadPacket();
      field.Encoding = Encoding;
      field.CatalogName = packet.ReadLenString();
      field.DatabaseName = packet.ReadLenString();
      field.TableName = packet.ReadLenString();
      field.RealTableName = packet.ReadLenString();
      field.ColumnName = packet.ReadLenString();
      field.OriginalColumnName = packet.ReadLenString();
      packet.ReadByte();
      field.CharacterSetIndex = packet.ReadInteger(2);
      field.ColumnLength = packet.ReadInteger(4);
      MySqlDbType type = (MySqlDbType)packet.ReadByte();
      ColumnFlags colFlags;
      if ((connectionFlags & ClientFlags.LONG_FLAG) != 0)
        colFlags = (ColumnFlags)packet.ReadInteger(2);
      else
        colFlags = (ColumnFlags)packet.ReadByte();
      field.Scale = (byte)packet.ReadByte();

      if (packet.HasMoreData)
      {
        packet.ReadInteger(2); // reserved
      }

      if (type == MySqlDbType.Decimal || type == MySqlDbType.NewDecimal)
      {
        field.Precision = (byte)(field.ColumnLength - 2);
        if ((colFlags & ColumnFlags.UNSIGNED) != 0)
          field.Precision++;
      }

      field.SetTypeAndFlags(type, colFlags);
    }
開發者ID:jimmy00784,項目名稱:mysql-connector-net,代碼行數:36,代碼來源:NativeDriver.cs

示例2: PrepareStatement

    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;
    }
開發者ID:jimmy00784,項目名稱:mysql-connector-net,代碼行數:45,代碼來源:NativeDriver.cs

示例3: ReadColumnValue

    public IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue valObject)
    {
      long length = -1;
      bool isNull;

      if (nullMap != null)
        isNull = nullMap[index + 2];
      else
      {
        length = packet.ReadFieldLength();
        isNull = length == -1;
      }

      packet.Encoding = field.Encoding;
      packet.Version = version;
      return valObject.ReadValue(packet, length, isNull);
    }
開發者ID:jimmy00784,項目名稱:mysql-connector-net,代碼行數:17,代碼來源:NativeDriver.cs

示例4: GetColumnsData

 public void GetColumnsData(MySqlField[] columns)
 {
   for (int i = 0; i < columns.Length; i++)
     GetColumnData(columns[i]);
   ReadEOF();
 }
開發者ID:jimmy00784,項目名稱:mysql-connector-net,代碼行數:6,代碼來源:NativeDriver.cs

示例5: PrepareStatement

 public virtual int PrepareStatement(string sql, ref MySqlField[] parameters)
 {
     return handler.PrepareStatement(sql, ref parameters);
 }
開發者ID:LittlePeng,項目名稱:ncuhome,代碼行數:4,代碼來源:Driver.cs

示例6: ReadColumnValue

 public IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue value)
 {
     return handler.ReadColumnValue(index, field, value);
 }
開發者ID:LittlePeng,項目名稱:ncuhome,代碼行數:4,代碼來源:Driver.cs

示例7: ReadColumnValue

 public abstract IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue value);
開發者ID:rykr,項目名稱:connector-net,代碼行數:1,代碼來源:Driver.cs

示例8: GetColumns

        public MySqlField[] GetColumns(int count)
        {
            MySqlField[] fields = new MySqlField[count];
            for (int i = 0; i < count; i++)
                fields[i] = new MySqlField(this);
            handler.GetColumnsData(fields);

            return fields;
        }
開發者ID:LittlePeng,項目名稱:ncuhome,代碼行數:9,代碼來源:Driver.cs

示例9: PrepareStatement

 public override int PrepareStatement(string sql, ref MySqlField[] parameters)
 {
   int statementId = base.PrepareStatement(sql, ref parameters);
   MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.StatementPrepared,
       Resources.TraceStatementPrepared, driverId, sql, statementId);
   return statementId;
 }
開發者ID:jimmy00784,項目名稱:mysql-connector-net,代碼行數:7,代碼來源:TracingDriver.cs

示例10: PrepareStatement

 public abstract int PrepareStatement(string sql, ref MySqlField[] parameters);
開發者ID:rykr,項目名稱:connector-net,代碼行數:1,代碼來源:Driver.cs

示例11: PrepareStatement

        public override int PrepareStatement(string sql, ref MySqlField[] parameters)
        {
            //TODO: check this
            //ClearFetchedRow();

            byte[] bytes = encoding.GetBytes(sql);
            ExecuteCommand(DBCmd.PREPARE, bytes, bytes.Length);

            stream.OpenPacket();

            int marker = stream.ReadByte();
            if (marker != 0)
                throw new MySqlException("Expected prepared statement marker");

            int statementId = stream.ReadInteger(4);
            int numCols = stream.ReadInteger(2);
            int numParams = stream.ReadInteger(2);
            //TODO: find out what this is needed for
            stream.ReadInteger(3);
            if (numParams > 0)
            {
                parameters = ReadColumnMetadata(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)
                {
                    stream.OpenPacket();
                    stream.SkipPacket();
                }

                ReadEOF();
            }

            return statementId;
        }
開發者ID:maanshancss,項目名稱:ClassLibrary,代碼行數:42,代碼來源:NativeDriver.cs

示例12: GetFieldMetaData41

        private MySqlField GetFieldMetaData41()
        {
            MySqlField field = new MySqlField(connection);

            stream.OpenPacket();
            field.Encoding = encoding;
            field.CatalogName = stream.ReadLenString();
            field.DatabaseName = stream.ReadLenString();
            field.TableName = stream.ReadLenString();
            field.RealTableName = stream.ReadLenString();
            field.ColumnName = stream.ReadLenString();
            field.OriginalColumnName = stream.ReadLenString();
            stream.ReadByte();
            field.CharacterSetIndex = stream.ReadInteger(2);
            field.ColumnLength = stream.ReadInteger(4);
            MySqlDbType type = (MySqlDbType) stream.ReadByte();
            ColumnFlags colFlags;
            if ((Flags & ClientFlags.LONG_FLAG) != 0)
                colFlags = (ColumnFlags) stream.ReadInteger(2);
            else
                colFlags = (ColumnFlags) stream.ReadByte();

            field.SetTypeAndFlags(type, colFlags);

            field.Scale = (byte) stream.ReadByte();


            if (stream.HasMoreData)
            {
                stream.ReadInteger(2); // reserved
            }

            if (charSets != null && field.CharacterSetIndex != -1)
            {
                CharacterSet cs = CharSetMap.GetChararcterSet(Version, (string) charSets[field.CharacterSetIndex]);
                field.MaxLength = cs.byteCount;
                field.Encoding = CharSetMap.GetEncoding(version, (string) charSets[field.CharacterSetIndex]);
            }

            return field;
        }
開發者ID:maanshancss,項目名稱:ClassLibrary,代碼行數:41,代碼來源:NativeDriver.cs

示例13: GetFieldMetaData

        private MySqlField GetFieldMetaData()
        {
            MySqlField field;

            if (version.isAtLeast(4, 1, 0))
                field = GetFieldMetaData41();
            else
            {
                stream.OpenPacket();
                field = new MySqlField(connection);

                field.Encoding = encoding;
                field.TableName = stream.ReadLenString();
                field.ColumnName = stream.ReadLenString();
                field.ColumnLength = stream.ReadNBytes();
                MySqlDbType type = (MySqlDbType) stream.ReadNBytes();
                stream.ReadByte();
                ColumnFlags colFlags;
                if ((Flags & ClientFlags.LONG_FLAG) != 0)
                    colFlags = (ColumnFlags) stream.ReadInteger(2);
                else
                    colFlags = (ColumnFlags) stream.ReadByte();
                field.SetTypeAndFlags(type, colFlags);

                field.Scale = (byte) stream.ReadByte();
                if (!version.isAtLeast(3, 23, 15) && version.isAtLeast(3, 23, 0))
                    field.Scale++;
            }

            return field;
        }
開發者ID:maanshancss,項目名稱:ClassLibrary,代碼行數:31,代碼來源:NativeDriver.cs

示例14: ReadColumnMetadata

        public override MySqlField[] ReadColumnMetadata(int count)
        {
            MySqlField[] fields = new MySqlField[count];

            for (int i = 0; i < count; i++)
                fields[i] = GetFieldMetaData();

            ReadEOF();
            return fields;
        }
開發者ID:maanshancss,項目名稱:ClassLibrary,代碼行數:10,代碼來源:NativeDriver.cs

示例15: ReadColumnValue

        public override IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue valObject)
        {
            long length = -1;
            bool isNull;

            if (nullMap != null)
                isNull = nullMap[index + 2];
            else
            {
                length = stream.ReadFieldLength();
                isNull = length == -1;
            }

            stream.Encoding = field.Encoding;
            return valObject.ReadValue(stream, length, isNull);
        }
開發者ID:maanshancss,項目名稱:ClassLibrary,代碼行數:16,代碼來源:NativeDriver.cs


注:本文中的MySql.Data.MySqlClient.MySqlField類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。