title: display/retrieve image from sql database in vb.net
body: <p>This should be pretty simple for a pro. I have images in sql server database and I want to retrieve them in my aspx (vb.net) file.
  I have in aspx this image control -
  
  in vb.net i have started this code -</p>
  
  <pre><code>Private Sub ImageDisplay()
      Dim SqlCnn As SqlConnection = Nothing, sql As String = ""
      ConnectDB(SqlCnn)
      Try
          sql = "SELECT image FROM employees (NOLOCK) WHERE ID =" &amp; emp_id
          sqlcmd = New SqlCommand(sqlstr, SqlCnn)
          Dim imageData As Byte() = DirectCast(sqlcmd.ExecuteScalar(), Byte())
          Dim newImage As Image = Nothing
          If Not imageData Is Nothing Then
              Using ms As New MemoryStream(imageData, 0, imageData.Length)
                  ms.Write(imageData, 0, imageData.Length)
                  newImage = Image.FromStream(ms, True)
              End Using
              image1.Image = newImage
          End If
      Catch ex As Exception
          ReportError(ex)
      Finally
          CloseDB(SqlCnn)
      End Try
  End Sub
  </code></pre>
  
  <p>I am getting error on 2 places. 
  -                     newImage = Image.FromStream(ms, True)
  -                image1.Image = newImage
  Fromstream is not a member of system.web.ui.webcontrols.image
  and second error Image is not a member of system.web.ui.webcontrols.image</p>