将保存在数据库中的图片信息生成缩略图的问题,请大家指导!
我使用的是vs2003 VB.net.
我想把保存在数据库中的图片文件,提取后,生成缩略图显示在网页上,以下是我的代码:
Dim con As New SqlClient.SqlConnection
Dim cmd As New SqlClient.SqlCommand
Dim fjnr() As Byte
con.ConnectionString = dbconstring
cmd.Connection = con
con.Open()
cmd.CommandText = "select fjnr from L_fj where id = " & fjid
fjnr = Convert.FromBase64String(cmd.ExecuteScalar())
Dim sfj As New System.IO.MemoryStream(fjnr)
img = System.Drawing.Image.FromStream(sfj,True)
其中fjid是图片的id号,在执行Dim sfj As New System.IO.MemoryStream(fjnr)时报错,image对象生成失败。
请各位帮忙指教。