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

Posted on 2008-11-05
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

    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

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now