From: Reggie Burnett Date: October 28 2004 7:08pm Subject: RE: Only byte arrays can be serialized by MySqlBinary List-Archive: http://lists.mysql.com/dotnet/96 Message-Id: <200410281908.i9SJ87O9005504@mail.mysql.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I have pushed a fix for this issue. The problem is that I want MySqlString to handle text fields of all sizes (varchar, tiny-, medium-, and longtext) but I don't define any enum values for those types. What I would like to do is define a "fake" datatype named Text that would represent all extended text types. However, keeping MySqlBinary only handling binary values and forcing new code to use MySqlDbType.Text for CLOB values would break a great deal of code, so instead I have modified MySqlBinary to handle any byte[][ and string values like this. internal override void Serialize(PacketWriter writer, bool binary, object ourValue, int length) { byte[] buffToWrite = null; if (ourValue is System.Byte[]) buffToWrite = (byte[])ourValue; else if (ourValue is String) { string s = (ourValue as string).Substring(0, length); buffToWrite = writer.Encoding.GetBytes(s); length = buffToWrite.Length; } if ( buffToWrite == null ) throw new MySqlException( "Only byte arrays and strings can be serialized by MySqlBinary" ); if (binary) { writer.WriteLength( length ); writer.Write( buffToWrite, 0, length ); } else { if ( writer.Version.isAtLeast(4,1,0)) writer.WriteStringNoNull( "_binary " ); writer.WriteByte( (byte)'\''); EscapeByteArray( buffToWrite, length, writer ); writer.WriteByte((byte)'\''); } } > -----Original Message----- > From: Barry Zubel [mailto:barry@stripped] > Sent: Thursday, October 28, 2004 9:53 AM > To: dotnet@stripped > Subject: RE: Only byte arrays can be serialized by MySqlBinary > > Ok, appears to be the conversion of the mediumtext field (NOTES in our > database) from a string value. > > In MySqlBinary.cs, around line 61: > > byte[] buff = (ourValue as System.Byte[]); > > Looks like casting ourValue to a System.Byte[] isn't working as (I) > expected. > > Delving further..... > > B. > > > -- > MySQL on .NET Mailing List > For list archives: http://lists.mysql.com/dotnet > To unsubscribe: http://lists.mysql.com/dotnet?unsub=reggie@stripped