Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/08/2010, 17:05
illus
 
Fecha de Ingreso: mayo-2010
Mensajes: 13
Antigüedad: 14 años
Puntos: 0
Sonrisa mostrar imagenes desde sql

hola tengo el siguiente codigo para mostrar las imagenes desde sql en mi formulario pero me marca un error al cargar la imagen en el picureBox
Espero que puedan ayudarme!!! try
{
SqlConnection myConnection = new SqlConnection(ConnectionString);
String mySelectQuery = "select nombre,imagen from datos where folio ='"+textBox1.Text+"'";
SqlCommand myCommand = new SqlCommand(mySelectQuery, myConnection);
myConnection.Open();
SqlDataReader myReader;
myReader = myCommand.ExecuteReader();

if (myReader.Read())
{
textBox3.Text = myReader.GetString(0).ToString();

byte[] bytBLOBData = new byte[myReader.GetBytes(1, 0, null, 0, int.MaxValue)];
myReader.GetBytes(1, 0, bytBLOBData, 0, bytBLOBData.Length);
MemoryStream stmBLOBDat = new MemoryStream(bytBLOBData);
pictureBox1.Image = Image.FromStream(stmBLOBDat);
}
else
{

myReader.Close();
myConnection.Close();
}

}
catch (SqlException ex)
{ MessageBox.Show("Error!: " + ex); }