title: Getting error as "Parameter is not valid" while fetching image from MySQL database to PictureBox (vb.net)
body: <p>I took a DataGridView and on MouseClick fetching data from database table 'products', column 'pimg'.<br>
  I took reference of this link <a href="https://www.sourcecodester.com/tutorials/visual-basic-net/12592/how-retrieve-image-mysql-database-using-vbnet.html" rel="nofollow noreferrer">https://www.sourcecodester.com/tutorials/visual-basic-net/12592/how-retrieve-image-mysql-database-using-vbnet.html</a><br>
  When I try to show fetched image in picturebox then it shows the error as "Parameter is not valid"</p>
  
  <pre><code>Private Sub DataGridViewdb_MouseClick(sender As Object, e As MouseEventArgs) Handles DataGridViewdb.MouseClick
          Dim connection As New MySqlConnection("datasource=localhost;port=3306;username=root;password=;database=id12302075_bdukan")
          Dim da As New MySqlDataAdapter
          Try
              Dim i As Integer
              i = DataGridViewdb.CurrentRow.Index
              Me.Labelid.Text = DataGridViewdb.Item(0, i).Value
              Me.TextBoxpid.Text = DataGridViewdb.Item(1, i).Value
              Me.TextBoxcid.Text = DataGridViewdb.Item(2, i).Value
              Me.TextBoxuid.Text = DataGridViewdb.Item(3, i).Value
              Me.TextBoxpname.Text = DataGridViewdb.Item(4, i).Value
              Me.TextBoxpyprice.Text = DataGridViewdb.Item(5, i).Value
              Me.TextBoxpprice.Text = DataGridViewdb.Item(6, i).Value
              Me.TextBoxpweight.Text = DataGridViewdb.Item(7, i).Value
              Me.TextBoxpstock.Text = DataGridViewdb.Item(8, i).Value
  
              connection.Open()
  
              Dim cmd = New MySqlCommand("select pimg from products where id='" &amp;
                DataGridViewdb.Item(0, i).Value &amp; "'", connection)
  
  
              Dim dt As New DataTable
  
              Dim arrImage() As Byte
  
              da.SelectCommand = cmd
              da.Fill(dt)
  
              arrImage = dt.Rows(0).Item(0)
              Dim mstream As New System.IO.MemoryStream(arrImage)
              PictureBox1.Image = Image.FromStream(mstream)
  
  
  
          Catch ex As Exception
              MessageBox.Show(ex.Message)
              da.Dispose()
              connection.Close()
  
          End Try
  
      End Sub
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/9LAOI.png" rel="nofollow noreferrer">enter image description here</a></p>