D
dmbuso
I have an Access database with a table named 'tblMedia'. In tblMedia I have a
field named 'Media' that is defined as an 'OLE Ojbect' field. In this Media
field, I have pictures, they are jpegs. I'm using VB.NET 2005 and I would
like to open the Access database and write the OLE Objects to the file system.
Here's what I got and it's not working.
'Open connection to the Access database
OpenConnection()
Dim Command As New OleDbCommand("SELECT * FROM TBLMEDIA WHERE
[MediaType]='Mug shot'", _DBConn)
Dim Reader As OleDbDataReader = Command.ExecuteReader()
Dim picture As Image = Nothing
'Read each line of TBLMEDIA and write out to Media file
While Reader.Read
'Place image on the clipboard
Dim pictureData As Byte() = CType(Reader.GetValue(3), Byte())
Using stream As New IO.MemoryStream(pictureData)
picture = Image.FromStream(stream)
End Using
My.Computer.Clipboard.SetImage(picture)
'Get the image from the clipboard
If My.Computer.Clipboard.ContainsImage() Then
picture = My.Computer.Clipboard.GetImage
'Write the image to a disk file
picture.Save(Me.txtDestFolder.Text & "\" &
Reader.GetValue(1).ToString & ".jpg")
End If
End While
I get a 'Parameter is not valid.' error on this line above:
picture = Image.FromStream(stream)
field named 'Media' that is defined as an 'OLE Ojbect' field. In this Media
field, I have pictures, they are jpegs. I'm using VB.NET 2005 and I would
like to open the Access database and write the OLE Objects to the file system.
Here's what I got and it's not working.
'Open connection to the Access database
OpenConnection()
Dim Command As New OleDbCommand("SELECT * FROM TBLMEDIA WHERE
[MediaType]='Mug shot'", _DBConn)
Dim Reader As OleDbDataReader = Command.ExecuteReader()
Dim picture As Image = Nothing
'Read each line of TBLMEDIA and write out to Media file
While Reader.Read
'Place image on the clipboard
Dim pictureData As Byte() = CType(Reader.GetValue(3), Byte())
Using stream As New IO.MemoryStream(pictureData)
picture = Image.FromStream(stream)
End Using
My.Computer.Clipboard.SetImage(picture)
'Get the image from the clipboard
If My.Computer.Clipboard.ContainsImage() Then
picture = My.Computer.Clipboard.GetImage
'Write the image to a disk file
picture.Save(Me.txtDestFolder.Text & "\" &
Reader.GetValue(1).ToString & ".jpg")
End If
End While
I get a 'Parameter is not valid.' error on this line above:
picture = Image.FromStream(stream)