Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello...!
I am getting error when i read the image from database i.e. LINQ
Code -
C#
if (objTblStudent.Photo != null)
{
    picStudPhoto.Image = byteArrayToImage(objTblStudent.Photo); // <-- Error
}

public Image byteArrayToImage(byte[] byteArrayIn)
{
    MemoryStream ms = new MemoryStream(byteArrayIn);
    Image returnImage = Image.FromStream(ms);
    return returnImage;
}

Above bold and italic line give me error like this -
The method or operation is not implemented
also i have implemented
C#
private Image byteArrayToImage(System.Data.Linq.Binary binary)
{
    throw new NotImplementedException();
}

please help me
Posted
Updated 5-Jan-15 21:24pm
v2
Comments
Tomas Takac 6-Jan-15 3:28am    
Did you check which of the two overloads of byteArrayToImage is called? I guess the latter. There you throw the exact exception you complain about.
dan!sh 6-Jan-15 3:39am    
Your method body is throwing the exception. What do you expect to happen?
George Swan 7-Jan-15 5:44am    
I would suggest that the reason that your 'not implimented' method is being called is that there is an implicit conversion between a byte array and a Binary, so the method will accept both types. I suggest that you remove that method and convert any Binary you may wish to use to a byte[] before passing it to the other method. You can use the binary.ToArray() method to do the conversion.

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