Click here to Skip to main content
12,951,289 members (57,193 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"))
                        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;

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

1 solution

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

Solution 1

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 to solve it???
WinnieMeeKun 28-Nov-12 3:11am
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
OriginalGriff 6,084
CHill60 3,480
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,830

Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 28 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