2
I have a table called "Subordinate" where users are registered with their respective photos. I have a form and need to display the photos of all registered users.
For this I have the following method:
private void ListarImagens()
{
strSql = "Select Imagem from Subordinado";
using (SqlConnection sqlCon = new SqlConnection(strCon))
{
SqlCommand cmd = new SqlCommand(strSql, sqlCon);
try
{
sqlCon.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
fotoArray = (byte[])reader["Imagem"];
MemoryStream ms = new MemoryStream(fotoArray);
pic1.Image = Image.FromStream(ms);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
sqlCon.Close();
}
}
}
Each registered photo should be shown in a different Picturebox and not being able to do it. How do I do that?
And what is the doubt/problem?
– Jéf Bueno
I edited the question
– Pedro Henrique Rocha