I have a table called "Subordinate" where users with their respective photos are registered. I have a form and I need to display the photos of all the 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 photo must be shown in a different PictureBox and can not do it. How do I do this?