[求助]从Access中读取图片,又出现异常了。。。
下面这段代码,一调用就会出现一个异常——未处理的“System.ArgumentException”类型的异常出现在 System.Drawing.dll 中。高手们帮我看看这是为什么吧?
Dim cn As System.Data.OleDb.OleDbConnection
Dim cmd As System.Data.OleDb.OleDbCommand
Dim dr As Data.OleDb.OleDbDataReader
Dim pictureColumn As Integer = 0
Dim b(1024 * 768) As Byte
Dim bs As System.IO.Stream = New System.IO.MemoryStream()
cn = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;" & _
"data source=E:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Loadpic\WindowsApplication1\Images.mdb")
cmd = New System.Data.OleDb.OleDbCommand("select * from Table1 WHERE id=" & 1, cn)
cn.Open()
dr = cmd.ExecuteReader()
dr.Read()
bs = New IO.MemoryStream(CType(dr("img"), Byte()))
PictureBox1.Image = Image.FromStream(bs)
dr.Close()
cn.Close()