Save and Retrieve Images From Database in WPF

You may also like...

11 Responses

  1. Aravindh says:

    hello admin,

    can u explain how to retrieve image from excel to gridview in wpf…

  2. Trieu says:

    Store image path or binary for good performance.
    Sorry my english very slow :)

    • Admin says:

      Hello Trieu,

      If your images are not many (like you just need to show images of some products on some page etc), then you can go on storing them in the DB.

      But if you have alot of images to work with in your application, then its better that you store only their paths in the DB and store the images on file system.

      Storing the images in the DB, helps securing them better than storing them on file system. But performance will certainly go low if you’ll have good amount of images and store then in DB. When images are stored on file system, their caching can also be done.


      • Trieu says:

        Hi Admin,

        Nice see your reply.
        My application store image employee (Size 3×4 or 4×6) so i’m thinking store image in DB for good:
        – One employee one image.
        – Total employee ~ 99999.


  3. Chandan M G says:

    please solve the error:

    if (row[0].ToString() == cbImages.SelectedItem.ToString())
    //Store binary data read from the database in a byte array
    byte[] blob = (byte[])row[1];
    MemoryStream stream = new MemoryStream();
    stream.Write(blob, 0, blob.Length);
    stream.Position = 0;

    An unhandled exception of type ‘System.InvalidCastException’ occurred in Manufacturing.exe

    Additional information: Unable to cast object of type ‘System.Decimal’ to type ‘System.Byte[]’.

  4. fakename says:

    Code tutorial was a livesaver! thanks!

  5. NABEEL ASLAM says:

    good article

  6. Steve says:

    Very good solution, much simpler than others I found. Thanks!

  7. Alejandro Ochoa says:

    Hello Admin,

    Can you explain how to add tha namespace for “System.Drawing”? please

  8. shan says:

    format of initialization string does not conform to specification starting at index 0
    i am facing this error how can i solve this reply me asap!

Leave a Reply to fakename Cancel reply

Your email address will not be published. Required fields are marked *

4 × = thirty six

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">