hi.i need help on this... i have a datagridview and when i clicked the datagridview shows in textbox and i have this one problem with my picture box...it only shows the same picture even if the saved picture in my database is not the same...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGet.Click
        If dgvUser.SelectedRows.Count > 0 Then
            Dim employeeID As Integer = Me.dgvUser.SelectedRows(0).Cells("ID").Value
            con.Open()
            Dim da As New OleDbDataAdapter("SELECT ID, mail, fname, gender, age, bdate, address, phone, uname, acctype, stats, picfile FROM login " & _
                                           " WHERE ID=" & employeeID, con)

            Dim dt As New DataTable
            da.Fill(dt)
            txtEmpId.Text = employeeID
            txtMail.Text = dt.Rows(0).Item("mail")
            txtName.Text = dt.Rows(0).Item("fname")
            cboGender.Text = dt.Rows(0).Item("gender")
            txtAge.Text = dt.Rows(0).Item("age")
            txtBdate.Text = dt.Rows(0).Item("bdate")
            txtAddress.Text = dt.Rows(0).Item("address")
            txtPhone.Text = dt.Rows(0).Item("phone")
            txtUserName.Text = dt.Rows(0).Item("uname")
            cboAccType.Text = dt.Rows(0).Item("acctype")
            cboStats.Text = dt.Rows(0).Item("stats")
            If Not IsDBNull(dt.Rows(0).Item("picfile")) Then
                PicImage = dt.Rows(0).Item("picfile")
                For Each pic As Byte In PicImage
                    myMs.WriteByte(pic)
                Next
                picPhoto.Image = System.Drawing.Image.FromStream(myMs)
            End If
            con.Close()
        End If
    End Sub
End Class

try below revised code:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGet.Click
            If dgvUser.SelectedRows.Count > 0 Then
                Dim employeeID As Integer = Me.dgvUser.SelectedRows(0).Cells("ID").Value
                con.Open()
                Dim da As New OleDbDataAdapter("SELECT ID, mail, fname, gender, age, bdate, address, phone, uname, acctype, stats, picfile FROM login " & _
                                               " WHERE ID=" & employeeID, con)
                Dim dt As New DataTable
                da.Fill(dt)
                txtEmpId.Text = employeeID
                txtMail.Text = dt.Rows(0).Item("mail")
                txtName.Text = dt.Rows(0).Item("fname")
                cboGender.Text = dt.Rows(0).Item("gender")
                txtAge.Text = dt.Rows(0).Item("age")
                txtBdate.Text = dt.Rows(0).Item("bdate")
                txtAddress.Text = dt.Rows(0).Item("address")
                txtPhone.Text = dt.Rows(0).Item("phone")
                txtUserName.Text = dt.Rows(0).Item("uname")
                cboAccType.Text = dt.Rows(0).Item("acctype")
                cboStats.Text = dt.Rows(0).Item("stats")
                If dt.Rows.Count > 0
                For i As Integer = 0 to dt.Rows.Count - 1
                If Not IsDBNull(dt.Rows(i).Item("picfile")) Then
                    PicImage = dt.Rows(i).Item("picfile")
                    For Each pic As Byte In PicImage
                        myMs.WriteByte(pic)
                    Next
                    picPhoto.Image = System.Drawing.Image.FromStream(myMs)
                End If
                Next
                End If
                con.Close()
            End If
        End Sub
    End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.