首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

vb.net 从数据库中读取图片显示在pictureBox有关问题

2012-02-05 
vb.net 从数据库中读取图片显示在pictureBox问题高手请进以下是读取图片的代码If aa.SqlCx(strsel).Rows.C

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
[解决办法]
楼上正解

热点排行