Click here to Skip to main content
12,395,645 members (57,889 online)
Rate this:
 
Please Sign up or sign in to vote.
using (SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\meekun.poon\\My Documents\\Visual Studio 2008\\Projects\\TrackLocation\\TrackLocation\\barcodePrinter.mdf;Integrated Security=True;User Instance=True"))
                    {
                        conn.Open();
                        using (SqlCommand cmd = new SqlCommand("SELECT ImageName FROM Image WHERE ImageID='PL001'", conn))
                        {
                            SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                            DataSet dataSet = new DataSet();
                            adpt.Fill(dataSet, "Image"); 
                            DataRow Row;
                            Row = dataSet.Tables["Image"].Rows[0];
                            byte[] MyImg = (byte[])Row[0];
                            MemoryStream ms = new MemoryStream(MyImg);
                            ms.Position = 0;
                                
                            Image img = Image.FromStream(ms); //error 
                            
                         pictureBox1.Image = img;
                            
                        }
                        conn.Close();
                    }
how to solve this problem??? imagename is image data type!! error message->parameter is not valid. URGENT!!! thanks
Posted 27-Nov-12 16:44pm
Updated 27-Nov-12 20:25pm
v3

1 solution

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

Solution 1

  Permalink  
Comments
WinnieMeeKun 27-Nov-12 23:03pm
   
my code only the Image img = Image.FromStream(ms);->got problem....why will like that??
Krunal R 27-Nov-12 23:05pm
   
What kinda error you're getting ?
shailendra194878 28-Nov-12 2:52am
   
hi WinnieMeeKun
how you save image in database binary format or saving path of image and keeping you images in folder.
WinnieMeeKun 28-Nov-12 0:46am
   
parameter is not valid-> error message..how to solve it???
WinnieMeeKun 28-Nov-12 3:11am
   
INSERT INTO Image
(ImageID,ImageName,Department)
VALUES ('PL002','C:\Documents and Settings\meekun.poon\My Documents\My Pictures\original plant layout\OSA Rework edited.jpeg','OSA REWORK')
***this is how i insert data into ms sql server 2005.
Satish rathore 28-Nov-12 3:25am
   
Please convert Image into binary before inserting into database.
WinnieMeeKun 28-Nov-12 9:37am
   
not already in binary form??? i save layout as image data type...i don't understand your meaning...

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.160721.1 | Last Updated 28 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