我有这个 SQL 数据库“Student”,我想将图像(全部或选定)从它的表“StudentPic”导出到具有“.jpg”扩展名的特定文件夹。
这是我的工作,但没有奏效。对此有何评论。?
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