Click here to Skip to main content
16,016,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have database, and i have a column that stored picture in access database
in that column i right click it and insert object which is picture from file
and it said "package" in the column  

the idea is i upload picture to 'pic' column in access database from file, and using 'querypic' table adapter query with parameter is 'comboname.text' is selected to return picture and store it as binary in byte of array

but when i convert it to image i got an error 
"System.ArgumentException: 'Parameter is not valid."

i checked my b() which is array of byte and it got result {length=40276}
can someone help me?


What I have tried:

<pre>Private Sub cmdSelect_Click(sender As Object, e As EventArgs) Handles cmdSelect.Click
            Dim facultytabeladapt As New CSE_DEPTDataSetTableAdapters.FacultyTableAdapter
            Dim b() As Byte
            Dim s As String
            b = facultytabeladapt.querypic(ComboName.Text)
    
            PhotoBox.Image = b21(b)
    
    
        End Sub
        Private Function b21(ByVal b() As Byte) As Image
    
            Dim imgc As New ImageConverter
    
            Dim imgpic As Image = CType(imgc.ConvertFrom(b), Image) 'it has error "System.ArgumentException: 'Parameter is not valid."
            Return imgpic
        End Function
Posted
Updated 7-Sep-18 3:20am
Comments
Richard MacCutchan 7-Sep-18 8:47am    
Which line does the error occur on? The message is telling you that you are passing a bad parameter to some method call.

1 solution

If it says "package" in the column, then it's stored as an OLE wrapper, rather than the raw bytes of the image.

Extracting images from OLE wrappers is somewhat complicated:
Convert Access image OLE Object into raw image byte array in C# - Stack Overflow[^]

It would probably be easier to change the column type to BLOB, and insert the raw image bytes from code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900