dotConnect for MySQL Documentation
Devart.Data.MySql Namespace / MySqlDataReader Class / GetMySqlBinaryString Method / GetMySqlBinaryString(String) Method
The name of the column to get value of.
Example

In This Topic
    GetMySqlBinaryString(String) Method
    In This Topic
    Gets the value of the specified column as a MySqlBinaryString object.
    Syntax
    'Declaration
     
    Public Overloads Function GetMySqlBinaryString( _
       ByVal name As String _
    ) As MySqlBinaryString
    public MySqlBinaryString GetMySqlBinaryString( 
       string name
    )

    Parameters

    name
    The name of the column to get value of.

    Return Value

    The value of the specified column as a MySqlBinaryString object.
    Example
    static void GetMyBinaryString(MySqlConnection connection) {
      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 = reader.GetMySqlBinaryString(i);
            value.Encoding = encoding;
            Console.WriteLine(value);
          }
    }
    Sub GetMyBinaryString(ByVal connection As MySqlConnection)
      Dim insertCommand As New MySqlCommand("INSERT INTO autotest.simple_types (f_binary, f_varbinary) VALUES (:p1, :p2)", connection)
      Dim encod As Encoding = Encoding.Unicode
      Dim buffer1 As Byte() = encod.GetBytes("test1")
      Dim buffer2 As Byte() = encod.GetBytes("test2")
      insertCommand.Parameters.Add("p1", New MySqlBinaryString(buffer1, encod))
      insertCommand.Parameters.Add("p2", New MySqlBinaryString(buffer2, encod))
      insertCommand.ExecuteNonQuery()
      Dim selectCommand As New MySqlCommand("SELECT f_binary, f_varbinary FROM autotest.simple_types", connection)
      Using reader As MySqlDataReader = selectCommand.ExecuteReader
        Do While reader.Read
          For i As Integer = 0 To reader.FieldCount - 1
            Dim value As MySqlBinaryString = reader.GetMySqlBinaryString(i)
            value.Encoding = encod
            Console.WriteLine(value)
          Next i
        Loop
      End Using
    End Sub
    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