Click here to Skip to main content
12,951,732 members (65,605 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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
Updated 26-Nov-12 19:48pm
Did you try to find available answer?
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
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:[^] (40 results),[^] (1326 results).

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


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.


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
OriginalGriff 6,239
CHill60 3,490
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,880

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