title: Byte conversion back to Image
body: <p>I'm trying to convert the bytes in plr.PlayerImage back into an image for the picturebox. </p>
  
  <p>However, Method 1 returns the error "Value of type Byte cannot be converted to 1-dimensional array of Byte" on plr.PlayerImage.</p>
  
  <p>Method 2 provides the error message "Conversion from type Byte() to type Byte is not valid".</p>
  
  <p>Method 1 works when used in a separate sub where I retrieve the data from the database, but won't work in my new sub:</p>
  
  <pre><code>Dim pictureData As Byte() = DirectCast(drResult("PlayerImage"), Byte())
  
                              Dim picture As Image = Nothing
  
                              'Create a stream in memory containing the bytes that comprise the image.
                              Using stream As New IO.MemoryStream(pictureData)
                                  'Read the stream and create an Image object from the data.'
                                  picture = Image.FromStream(stream)
                              End Using
  
                              UC_Menu_Scout1.PictureBox1.Image = picture
  </code></pre>
  
  <p>Current Code:</p>
  
  <pre><code>Private Sub fillPlayerInfo()
  
              For Each plr As Player In getAllPlayers()
  
                  If lbPlayers.SelectedItem.PlayerID = plr.PlayerID Then
  
                      txtFirstName.Text = plr.PlayerFirstName
                      txtSurname.Text = plr.PlayerLastName
                      txtPlaceOfBirth.Text = plr.PlaceOfBirth
                      cmbClub.SelectedValue = plr.ClubID
                      dtpDOB.Value = plr.DOB
  
                      '**********Method 1*********************************************
                      Dim pictureData As Byte() = DirectCast(plr.PlayerImage, Byte())
                      Dim picture As Image = Nothing
  
                      'Create a stream in memory containing the bytes that comprise the image.
                      Using stream As New IO.MemoryStream(pictureData)
                          'Read the stream and create an Image object from the data.
                          picture = Image.FromStream(stream)
                      End Using
  
                      '**********Method 2*********************************************
                      Dim ms As New IO.MemoryStream(plr.PlayerImage)
                      Dim returnImage As Image = Image.FromStream(ms)
  
                      pcbEditPlayer.Image = returnImage
  
                  End If
              Next
  
          End Sub
  </code></pre>