1 Replies - 6232 Views - Last Post: 15 April 2010 - 03:39 PM Rate Topic: -----

#1 Backtracker  Icon User is offline

  • D.I.C Head

Reputation: -23
  • View blog
  • Posts: 163
  • Joined: 30-November 08

Convert From "Byte" to "1-dimensional array of byte"

Posted 15 April 2010 - 03:23 PM

Value type "Byte" cannot be converted into "1-dimensional array of byte"
Does anyone know what is missing?

Option Strict On


    Private Function MySQLDataReader_GetByte(ByVal Connection As MySqlConnection, ByVal CommandText As String, ByVal Column As String) As Byte()
        ' Declare the mysqlcommand and the mysqlreader.
        Dim Command As MySqlCommand
        Dim Reader As MySqlDataReader
        Dim Data As Byte()

        Try
            ' Create a new command.
            Command = New MySqlCommand(CommandText, Connection)

            ' Execute the reader.
            Reader = Command.ExecuteReader

            ' Execute the read command.
            Reader.Read()

            If Reader.HasRows Then
                ' Read the data.
                ' Here is where im having the error.
                Data = Reader.GetByte(Column)
            End If

            ' Close the reader.
            Reader.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

        Return Data
    End Function

This post has been edited by Backtracker: 15 April 2010 - 03:24 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Convert From "Byte" to "1-dimensional array of byte"

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Convert From "Byte" to "1-dimensional array of byte"

Posted 15 April 2010 - 03:39 PM

I think you need to look at MySqlDataReader.GetBytes instead of GetByte. GetByte returns only a single byte and your variable is declared as a byte array
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1