System.NotSupportedException HResult=0x80131515 Message=No imaging component suitable to complete this operation was found

0
  1. i am saving image and retrieving the image from sql server 2017 and when i am retrieving exception shows

  2. error " System.NotSupportedException HResult=0x80131515 Message=No imaging component suitable to complete this operation was found"

  3. microsoft sql server studio 2017

  4. follow is a code block for retrieving image from sql server 2017

    SqlConnection con;
    String sqlstr = "select photo from img Where itmNO='" + txt1.Text +  "'";
    string conString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
    con = new SqlConnection(conString);
    con.Open();
    SqlCommand cmd1 = new SqlCommand(sqlstr, con);
    object value = cmd1.ExecuteScalar();
    byte[] imageData = (byte[])value;
    if (imageData != null && imageData.Length > 0)
    {
    var imag = new BitmapImage();
    using (var mem = new MemoryStream(imageData))
    {
            mem.Position = 0;
            mem.Write(imageData, 0, imageData.Length - 0);
            imag.BeginInit();
            imag.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
            imag.CacheOption = BitmapCacheOption.OnLoad;
            imag.UriSource = null;
            imag.StreamSource = mem;
            imag.EndInit();
     }
     imag.Freeze();
     img2.Source = imag;
     }
    

5.thanks in advance when i am saving byte array byte length is showing 84254 but when retrieving it's length shows 13 only but i am unable to understand why it is happening

c#
wpf
asked on Stack Overflow May 19, 2019 by Govind Dubey

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0