Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
i have table in my database and having fields like StudentId and StudImage. Iam using wcf services.

I cause error in IvalueConverter.Please tell me How to convert Byte[] to binary.

Thanks&Regards,
swathi
Posted
Comments
Anuja Pawar Indore 27-Jan-12 1:50am    
Post your code. Not clear
Sergey Alexandrovich Kryukov 27-Jan-12 1:59am    
What does it mean "to binary"?! Is byte[] not binary enough?
Make no sense whatsoever.

For goodness sake, what error?
--SA
OriginalGriff 27-Jan-12 3:13am    
We need to know the error message, and the line which caused it.
In addition, we need a small amount of code around that line to give us some context for what the line is doing - if it is short enough, then the method should suffice.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

found on CP: C# Save and Load Image from Database[^]

other example code:
C#
SqlCommand cmd = new SqlCommand("select StudImagefrom tablename where id = 1");
SqlDataReader dataReader = cmd.ExecuteReader();
byte[] imageBytes = (byte[]) imageReader.GetValue(0); 
MemoryStream ms = new MemoryStream(imageBytes); 
FileStream fs = File.OpenWrite(imagePath);fs.Write(ms.GetBuffer(), 0, ms.Position());
 
Share this answer
 
v2
Comments
swathi from Hyderabad, Andhra Pradesh 28-Jan-12 0:24am    
Thank you for your reply...it is very useful for me

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