Click here to Skip to main content
11,647,810 members (61,966 online)
Rate this: bad
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
Sergey Alexandrovich Kryukov at 27-Nov-12 2:22am
Did you try to find available answer?
WinnieMeeKun at 27-Nov-12 4:24am
i tried so many solution, still cannot solve the problem.
shivajikaka1988 at 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
0 500
1 F-ES Sitecore 410
2 DamithSL 290
3 CPallini 290
4 OriginalGriff 277
0 OriginalGriff 1,342
1 994
2 DamithSL 971
3 Sergey Alexandrovich Kryukov 873
4 CPallini 845

Advertise | Privacy | Mobile
Web04 | 2.8.150804.4 | Last Updated 27 Nov 2012
Copyright © CodeProject, 1999-2015
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