I have this SQL database "Student" and I want to export images(all or selected) from it's table "StudentPic" to a specific folder with ".jpg" extension.
This is my work and it didn't work. Any comments about this.?
Dim sql As String = " SELECT TOP 10 StudID,StudentPic FROM Student"
Dim cmd As SqlCommand = New SqlCommand(sql, conn)
conn.Open
Dim dr As SqlDataReader = cmd.ExecuteReader
While dr.Read
Dim bytes() As Byte = CType(dr("StudentPic"),Byte())
Dim memStream As MemoryStream = New MemoryStream(bytes)
Try
Dim MyImage As Bitmap = New Bitmap(memStream)
MyImage = New Bitmap(MyImage, 200, 250)
MyImage.Save((dr("StudID") + ".jpg"), ImageFormat.Jpeg)
Catch ex As Exception
Throw ex
End Try
End While