Click here to Skip to main content
12,356,154 members (70,510 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
SqlDataAdapter dataAdapter = new SqlDataAdapter(new SqlCommand("SELECT ImageName FROM Image WHERE Department='OSA REWORK'", con));
                    DataSet dataSet = new DataSet();
                    dataAdapter.Fill(dataSet, "Image");
 if (dataSet.Tables["Image"].Rows.Count > 0)
                    {
 
                        MemoryStream ms = new MemoryStream((byte[])dataSet.Tables["Image"].Rows[0]["ImageName"]);
                        ms.Position = 0;
                       
                 pictureBox1.Image = Image.FromStream(ms);//>error        
            }
Posted 26-Nov-12 19:45pm
Edited 26-Nov-12 19:48pm
__TR__29K
v2
Comments
   
Did you try to find available answer?
--SA
WinnieMeeKun 27-Nov-12 4:24am
   
i tried so many solution, still cannot solve the problem.
shivajikaka1988 3-May-13 10:35am
   
this code is not working

1 solution

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

Solution 1

This rather boring question is asked so frequently that answering again would be wrong. Start with looking for existing answers:
http://www.codeproject.com/search.aspx?doctypeid=5&q=database+%28image+OR+images%29+PictureBox[^] (40 results),
http://www.codeproject.com/search.aspx?doctypeid=5&q=database+%28image+OR+images%29[^] (1326 results).

The number of found results shown at the moment of writing.

[EDIT]

In your case, you need to debug your code to see what's in the stream. For a test, you could simply copy your stream to a file stream to see if it's a valid file or not. It could be incorrectly written in first place. It could be a file name instead of file content — many different problems are possible.

—SA
  Permalink  
v3

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 27 Nov 2012
Copyright © CodeProject, 1999-2016
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