当前位置: 首页>>代码示例>>C#>>正文


C# MySqlPacket.WriteStringNoNull方法代码示例

本文整理汇总了C#中MySql.Data.MySqlClient.MySqlPacket.WriteStringNoNull方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlPacket.WriteStringNoNull方法的具体用法?C# MySqlPacket.WriteStringNoNull怎么用?C# MySqlPacket.WriteStringNoNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MySql.Data.MySqlClient.MySqlPacket的用法示例。


在下文中一共展示了MySqlPacket.WriteStringNoNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1:

 void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
 {
   double v = (val is double) ? (double)val : Convert.ToDouble(val);
   if (binary)
     packet.Write(BitConverter.GetBytes(v));
   else
     packet.WriteStringNoNull(v.ToString("R", CultureInfo.InvariantCulture));
 }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:8,代码来源:MySqlDouble.cs

示例2:

 void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
 {
   byte v = (val is byte) ? (byte)val : Convert.ToByte(val);
   if (binary)
     packet.WriteByte(v);
   else
     packet.WriteStringNoNull(v.ToString());
 }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:8,代码来源:MySqlUByte.cs

示例3:

 void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
 {
   int v = (val is UInt16) ? (UInt16)val : Convert.ToUInt16(val);
   if (binary)
     packet.WriteInteger((long)v, 2);
   else
     packet.WriteStringNoNull(v.ToString());
 }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:8,代码来源:MySqlUInt16.cs

示例4:

 void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
 {
   long v = (val is Int64) ? (Int64)val : Convert.ToInt64(val);
   if (binary)
     packet.WriteInteger(v, 8);
   else
     packet.WriteStringNoNull(v.ToString());
 }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:8,代码来源:MySqlInt64.cs

示例5:

 void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object v, int length)
 {
     uint val = (v is uint) ? (uint)v : Convert.ToUInt32(v);
     if (binary)
         packet.WriteInteger((long)val, is24Bit ? 3 : 4);
     else
         packet.WriteStringNoNull(val.ToString());
 }
开发者ID:zibler,项目名称:zibler,代码行数:8,代码来源:MySqlUInt32.cs

示例6: Guid

    void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
    {
      Guid guid = Guid.Empty;
      string valAsString = val as string;
      byte[] valAsByte = val as byte[];

      if (val is Guid)
        guid = (Guid)val;
      else
      {
        try
        {
          if (valAsString != null)
            guid = new Guid(valAsString);
          else if (valAsByte != null)
            guid = new Guid(valAsByte);
        }
        catch (Exception ex)
        {
          throw new MySqlException(Resources.DataNotInSupportedFormat, ex);
        }
      }

      if (OldGuids)
        WriteOldGuid(packet, guid, binary);
      else
      {
        guid.ToString("D");

        if (binary)
          packet.WriteLenString(guid.ToString("D"));
        else
          packet.WriteStringNoNull("'" + MySqlHelper.EscapeString(guid.ToString("D")) + "'");
      }
    }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:35,代码来源:MySqlGuid.cs

示例7: WriteOldGuid

    private void WriteOldGuid(MySqlPacket packet, Guid guid, bool binary)
    {
      byte[] bytes = guid.ToByteArray();

      if (binary)
      {
        packet.WriteLength(bytes.Length);
        packet.Write(bytes);
      }
      else
      {
        packet.WriteStringNoNull("_binary ");
        packet.WriteByte((byte)'\'');
        EscapeByteArray(bytes, bytes.Length, packet);
        packet.WriteByte((byte)'\'');
      }
    }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:17,代码来源:MySqlGuid.cs

示例8:

 void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
 {
   int v = (val is Int32) ? (int)val : Convert.ToInt32(val);
   if (binary)
     packet.WriteInteger((long)v, is24Bit ? 3 : 4);
   else
     packet.WriteStringNoNull(v.ToString());
 }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:8,代码来源:MySqlInt32.cs

示例9: MySqlException

        void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
        {
            byte[] buffToWrite = (val as byte[]);
            if (buffToWrite == null)
            {
                char[] valAsChar = (val as Char[]);
                if (valAsChar != null)
                    buffToWrite = packet.Encoding.GetBytes(valAsChar);
                else
                {
                    string s = val.ToString();
                    if (length == 0)
                        length = s.Length;
                    else
                        s = s.Substring(0, length);
                    buffToWrite = packet.Encoding.GetBytes(s);
                }
            }

            // we assume zero length means write all of the value
            if (length == 0)
                length = buffToWrite.Length;

            if (buffToWrite == null)
                throw new MySqlException("Only byte arrays and strings can be serialized by MySqlBinary");

            if (binary)
            {
                packet.WriteLength(length);
                packet.Write(buffToWrite, 0, length);
            }
            else
            {
                if (packet.Version.isAtLeast(4, 1, 0))
                    packet.WriteStringNoNull("_binary ");

                packet.WriteByte((byte)'\'');
                EscapeByteArray(buffToWrite, length, packet);
                packet.WriteByte((byte)'\'');
            }
        }
开发者ID:NoxHarmonium,项目名称:rmitjourneyplanner,代码行数:41,代码来源:MySqlBinary.cs

示例10: MySqlException

		void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
		{
			if (!(val is TimeSpan))
				throw new MySqlException("Only TimeSpan objects can be serialized by MySqlTimeSpan");

			TimeSpan ts = (TimeSpan)val;
			bool negative = ts.TotalMilliseconds < 0;
			ts = ts.Duration();

			if (binary)
			{
				packet.WriteByte(8);
				packet.WriteByte((byte)(negative ? 1 : 0));
				packet.WriteInteger(ts.Days, 4);
				packet.WriteByte((byte)ts.Hours);
				packet.WriteByte((byte)ts.Minutes);
				packet.WriteByte((byte)ts.Seconds);
			}
			else
			{
				String s = String.Format("'{0}{1} {2:00}:{3:00}:{4:00}.{5}'",
					negative ? "-" : "", ts.Days, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);

				packet.WriteStringNoNull(s);
			}
		}
开发者ID:seeseekey,项目名称:CSCL,代码行数:26,代码来源:MySqlTime.cs

示例11: MySqlGeometry

        void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
        {
            byte[] buffToWrite = null;

              try
              {
            buffToWrite = ((MySqlGeometry)val)._valBinary;
              }
              catch
              {
            buffToWrite = val as Byte[];
              }

              if (buffToWrite == null)
              {
            MySqlGeometry v = new MySqlGeometry(0, 0);
            MySqlGeometry.TryParse(val.ToString(), out v);
            buffToWrite = v._valBinary;
              }

              byte[] result = new byte[GEOMETRY_LENGTH];

              for (int i = 0; i < buffToWrite.Length; i++)
              {
               if (buffToWrite.Length < GEOMETRY_LENGTH)
             result[i + 4] = buffToWrite[i];
               else
            result[i] = buffToWrite[i];
              }

            packet.WriteStringNoNull("_binary ");
            packet.WriteByte((byte)'\'');
            EscapeByteArray(result, GEOMETRY_LENGTH, packet);
            packet.WriteByte((byte)'\'');
        }
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:35,代码来源:MySqlGeometry.cs

示例12: SerializeText

        private void SerializeText(MySqlPacket packet, MySqlDateTime value)
        {
            string val = String.Empty;

            if (type == MySqlDbType.Timestamp && !packet.Version.isAtLeast(4, 1, 0))
                val = String.Format("{0:0000}{1:00}{2:00}{3:00}{4:00}{5:00}",
                    value.Year, value.Month, value.Day, value.Hour, value.Minute, value.Second);
            else
            {
                val = String.Format("{0:0000}-{1:00}-{2:00}",
                    value.Year, value.Month, value.Day);
                if (type != MySqlDbType.Date)
                    val = String.Format("{0} {1:00}:{2:00}:{3:00}", val,
                        value.Hour, value.Minute, value.Second);
            }
            packet.WriteStringNoNull("'" + val + "'");
        }
开发者ID:NoxHarmonium,项目名称:rmitjourneyplanner,代码行数:17,代码来源:MySqlDateTime.cs

示例13: WriteValue

 public void WriteValue(MySqlPacket packet, bool binary, object value, int length)
 {
     var v = (value is bool) ? (bool)value : Convert.ToBoolean(value);
     if (binary)
         packet.WriteInteger((long) (v ? 1 : 0), 8);
     else
         packet.WriteStringNoNull(v.ToString());
 }
开发者ID:BGCX261,项目名称:zp-mysql-data-svn-to-git,代码行数:8,代码来源:MySqlBit.cs

示例14: Serialize

 internal void Serialize(MySqlPacket packet, bool binary, MySqlConnectionStringBuilder settings)
 {
   if (!binary && (paramValue == null || paramValue == DBNull.Value))
     packet.WriteStringNoNull("NULL");
   else
   {
     if (ValueObject.MySqlDbType == MySqlDbType.Guid)
     {
       var g = (MySqlGuid)ValueObject;
       g.OldGuids = settings.OldGuids;
       valueObject = g;
     }
     ValueObject.WriteValue(packet, binary, paramValue, size);
   }
 }
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:15,代码来源:parameter.cs

示例15:

        void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length)
        {
            string v = val.ToString();
            if (length > 0)
            {
                length = Math.Min(length, v.Length);
                v = v.Substring(0, length);
            }

            if (binary)
                packet.WriteLenString(v);
            else
                packet.WriteStringNoNull("'" + MySqlHelper.EscapeString(v) + "'");
        }
开发者ID:BGCX261,项目名称:zp-mysql-data-svn-to-git,代码行数:14,代码来源:MySqlString.cs


注:本文中的MySql.Data.MySqlClient.MySqlPacket.WriteStringNoNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。