dotConnect for MySQL Documentation
Devart.Data.MySql Namespace / MySqlBinaryString Structure
Members Example

MySqlBinaryString Structure
Represents MySQL BINARY and VARBINARY types.
Syntax
Remarks
This structure manages BINARY and VARBINARY as strings with certain encoding (specified with the Encoding property).
Example
The following example demonstrates how to insert and fetch text data using binary types.
MySqlCommand insertCommand = new MySqlCommand("insert into autotest.simple_types (f_binary, f_varbinary) values (:p1, :p2)", connection);

Encoding encoding = Encoding.Unicode;
byte[] buffer1 = encoding.GetBytes("test1");
byte[] buffer2 = encoding.GetBytes("test2");

insertCommand.Parameters.Add("p1", new MySqlBinaryString(buffer1, encoding));
insertCommand.Parameters.Add("p2", new MySqlBinaryString(buffer2, encoding));
insertCommand.ExecuteNonQuery();

MySqlCommand selectCommand = new MySqlCommand("select f_binary, f_varbinary from autotest.simple_types", connection);

using (MySqlDataReader reader = selectCommand.ExecuteReader())
 while (reader.Read())
   for (int i = 0; i < reader.FieldCount; ++i) {
     MySqlBinaryString value = (MySqlBinaryString)reader.GetProviderSpecificValue(i);
     value.Encoding = encoding;
     Console.WriteLine(value);
   }
Inheritance Hierarchy

System.Object
   System.ValueType
      Devart.Data.MySql.MySqlBinaryString

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also