读书人

vb.net 从数据库中读取图片显示在pict

发布时间: 2012-02-05 12:07:15 作者: rapoo

vb.net 从数据库中读取图片显示在pictureBox问题 高手请进
以下是读取图片的代码

If aa.SqlCx(strsel).Rows.Count > 0 Then
Dim ByteArr As Byte() = aa.SqlCx(strsel).Rows(0)(0)
If ByteArr.Length > 0 Then
Dim Stream As New MemoryStream(ByteArr, True)
Stream.Write(ByteArr, 0, ByteArr.Length)

PictureBox1.Image = New Bitmap(Stream) 错误(参数无效)

Stream.Close()
Else
MsgBox("没有图片")
End If
End If
这是什么原因????????????

[解决办法]

VB.NET code
If aa.SqlCx(strsel).Rows.Count >  0 Then       Dim ByteArr As Byte() = aa.SqlCx(strsel).Rows(0)(0)       If ByteArr.Length >  0 Then           Dim Stream As New MemoryStream(ByteArr, True)           Stream.Write(ByteArr, 0, ByteArr.Length) '问题在这里,这一行是多余而且有错误的.                             PictureBox1.Image = New Bitmap(Stream)              Stream.Close()       Else                 MsgBox("没有图片")       End If End If
[解决办法]
楼上正解

读书人网 >VB Dotnet

热点推荐