Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
this is my code. But i cannot display the image into picture box. i use image data type as imageContent for store image. Can i know how to solve this problem??
 

SqlCommand sqlCmd = new SqlCommand("SELECT imageContent FROM printerBarCode pbc,PlantLayout pl WHERE pbc.Department=pl.Department,pbc.Location=pl.Location", con);
                        SqlDataAdapter SDA1 = new SqlDataAdapter(sqlCmd);
                        DataSet ds = new DataSet();  
                        SDA1.Fill(ds, "PlantLayout");  
                        int c = ds.Tables["Plantlayout"].Rows.Count; 
                         {   //BLOB is read into Byte array, then used to construct MemoryStream,  
                             //then passed to PictureBox.  
                            
                            Byte[] byteBLOBData = new Byte[0];  
                           byteBLOBData = (Byte[])(ds.Tables["PlantLayout"].Rows[c - 1]["imageContent"]);
                          
                         MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);  
                           
                           pictureBox1.Image = Image.FromStream(stmBLOBData); 
                         }
Posted 20-Nov-12 17:06pm
Edited 20-Nov-12 17:42pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

still pop up the message"Invalid data"...
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

USE THIS
 
 
MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);  
                           
                           pictureBox1.Image = Image.FromStream(stmBLOBData); 
           Bitmap bmpImage = new Bitmap(ms);
            pictureBox1.Image = bmpImage ;
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 383
1 Richard Deeming 180
2 ChauhanAjay 176
3 Sergey Alexandrovich Kryukov 171
4 Yogesh Kumar Tyagi 165
0 Sergey Alexandrovich Kryukov 6,252
1 OriginalGriff 5,498
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100