G
Guest
I am trying to display images from an Access 2000 database and I get an error
"Invalid Parameter Used" when I execute the code line
"picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual Basic .Net
application.
I have researched MSDN for help and found the example article 321900 (see
below) and set up a test and everything works fine when I use SQL Server 2000
but when I modify the code and use data from Access 2000 using an
"OleDbDataAdapter" I get the error.
I tried a work around by importing my Access 2000 database into a SQL Server
data file and I get the same error using the sample code. If I load a picture
(jpg) into a SQL Server file and use the code sample it work but if I load
the same picture file into an Access 2000 file the code sample dosen't work.
What am I missing? Is There a parameter that I need when I use Access 2000?
How To Display an Image from a Database in a Windows Forms PictureBox by
Using Visual Basic .NET
Article ID : 321900 Last Review : July 15, 2004 Revision : 1.0
7. Add the following code in the Click event procedure of Button2:
Dim cn As New SqlConnection(strCn)
Dim cmd As New SqlCommand("SELECT BLOBID, " & _
"BLOBData FROM BLOBTest ORDER BY BLOBID", cn)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
da.Fill(ds, "BLOBTest")
Dim c As Integer = ds.Tables("BLOBTest").Rows.Count
If c > 0 Then
Dim bytBLOBData() As Byte = _
ds.Tables("BLOBTest").Rows(c - 1)("BLOBData")
Dim stmBLOBData As New MemoryStream(bytBLOBData)
picBLOB.Image = Image.FromStream(stmBLOBData)
End If
"Invalid Parameter Used" when I execute the code line
"picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual Basic .Net
application.
I have researched MSDN for help and found the example article 321900 (see
below) and set up a test and everything works fine when I use SQL Server 2000
but when I modify the code and use data from Access 2000 using an
"OleDbDataAdapter" I get the error.
I tried a work around by importing my Access 2000 database into a SQL Server
data file and I get the same error using the sample code. If I load a picture
(jpg) into a SQL Server file and use the code sample it work but if I load
the same picture file into an Access 2000 file the code sample dosen't work.
What am I missing? Is There a parameter that I need when I use Access 2000?
How To Display an Image from a Database in a Windows Forms PictureBox by
Using Visual Basic .NET
Article ID : 321900 Last Review : July 15, 2004 Revision : 1.0
7. Add the following code in the Click event procedure of Button2:
Dim cn As New SqlConnection(strCn)
Dim cmd As New SqlCommand("SELECT BLOBID, " & _
"BLOBData FROM BLOBTest ORDER BY BLOBID", cn)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
da.Fill(ds, "BLOBTest")
Dim c As Integer = ds.Tables("BLOBTest").Rows.Count
If c > 0 Then
Dim bytBLOBData() As Byte = _
ds.Tables("BLOBTest").Rows(c - 1)("BLOBData")
Dim stmBLOBData As New MemoryStream(bytBLOBData)
picBLOB.Image = Image.FromStream(stmBLOBData)
End If