Reading image from Access - parameter not valid

前端 未结 2 657

I have simple database in Access .mdb file, but I don\'t know how to deal with: \"parameter not valid\" exception when Im creating Image from stream. I\'v read

2条回答
  •  抹茶落季
    2020-12-11 18:01

    I do not believe that your problem is with the database. "Parameter not valid" exceptions when dealing with imaging can be a total pain as I have dealt with them before. They're not very clear on what the problem is.

    How exactly was the image placed into the database? There could be a problem with writing the image into the database before you've even attempted to pull it. Also, what file type is the image?

    EDIT Here is some sample code that I've used before to get an image from a byte array.

            //takes an array of bytes and converts them to an image.
        private Image getImageFromBytes(byte[] myByteArray)
        {            
            System.IO.MemoryStream newImageStream = new System.IO.MemoryStream(myByteArray, 0, myByteArray.Length);
            return Image.FromStream(newImageStream, true);
        }
    

提交回复
热议问题