當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。