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("S ELECT * FROM TBLMEDIA WHERE
[MediaType]='Mug shot'", _DBConn)
Dim Reader As OleDbDataReader = Command.Execute Reader()
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.Ge tValue(3), Byte())
Using stream As New IO.MemoryStream (pictureData)
picture = Image.FromStrea m(stream)
End Using
My.Computer.Cli pboard.SetImage (picture)
'Get the image from the clipboard
If My.Computer.Cli pboard.Contains Image() Then
picture = My.Computer.Cli pboard.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.FromStrea m(stream)
--
Dave B.
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("S ELECT * FROM TBLMEDIA WHERE
[MediaType]='Mug shot'", _DBConn)
Dim Reader As OleDbDataReader = Command.Execute Reader()
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.Ge tValue(3), Byte())
Using stream As New IO.MemoryStream (pictureData)
picture = Image.FromStrea m(stream)
End Using
My.Computer.Cli pboard.SetImage (picture)
'Get the image from the clipboard
If My.Computer.Cli pboard.Contains Image() Then
picture = My.Computer.Cli pboard.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.FromStrea m(stream)
--
Dave B.
Comment