0

I'm trying to show image from mysql to PictureBox, and I set it to show on a form load. But when my form loads, picture doesn't appear, and the code shows no errors. Here's the code:

Private Sub frmStudentskiPanel_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    Konekcija = New MySqlConnection
    Konekcija.ConnectionString = "server=localhost; userid=root; password=masterzlaja123; database=proba"
    Dim Command As MySqlCommand
    Dim reader As MySqlDataReader
    Dim img() As Byte

    Try
        Konekcija.Open()
        Dim Query As String
        Query = "Select Slika from proba.studenti where Korisnicko_ime = '" & Label2.Text & "' "
        Command = New MySqlCommand(Query, Konekcija)
        reader = Command.ExecuteReader
        While reader.Read()
            img = reader.Item("Slika")
            Dim mstream As New MemoryStream(img)
            PictureBox1.Image = Image.FromStream(mstream)
        End While

        Konekcija.Close()
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    Finally
        Konekcija.Dispose()
    End Try

End Sub

End Class

0 Answers0