[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Cannot convert type 'System.Data.Linq.Binary' to byte

Posted on 2008-11-05
Medium Priority
Last Modified: 2012-06-22
I would like to get an image from linq & add it to a PictureBox.image.
I get the following error.......
Cannot convert type 'System.Data.Linq.Binary' to byte
My Code >>>>

using (EmployeeDataContext EmployeeCtx = new EmployeeDataContext(GlobalMethods.SqlConnectionString))
                    var rsEmpTerminals = (from e in EmployeeCtx.Employees
                                          where e.Emp_EmployeeNumber_VC16 == empNo
                                          select e);

                    foreach (var item in rsEmpTerminals)
                             byte[] Empimage = (byte[])(item.Emp_Pic_IMG);
                             MemoryStream ms = new MemoryStream(Empimage);
                             pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
                             pictureBox.Image = Bitmap.FromStream(ms);

Also this does not work

 pictureBox.Image = item.Emp_Pic_IMG;
Question by:u2envy1
1 Comment

Accepted Solution

u2envy1 earned 0 total points
ID: 22885570
I found the problem......
In the .dbml where the table lies. Just right click on the field -> choose propeties. Change Type from Binary (System.Data.Linq.Binary) To byte[] (System.Byte[]) & use the code from above.
Hope this helps some1 out their !! :-)

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question