Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL-server-2005 C#
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 17:44pm
Edited 27-Nov-12 21:25pm

1 solution

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

Solution 1

WinnieMeeKun at 27-Nov-12 23:03pm
my code only the Image img = Image.FromStream(ms);->got problem....why will like that??
Krunal R at 27-Nov-12 23:05pm
What kinda error you're getting ?
shailendra194878 at 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 at 28-Nov-12 0:46am
parameter is not valid-> error to solve it???
WinnieMeeKun at 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 at 28-Nov-12 3:25am
Please convert Image into binary before inserting into database.
WinnieMeeKun at 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
0 OriginalGriff 7,215
1 DamithSL 5,114
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,747
4 Kornfeld Eliyahu Peter 4,514

Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 28 Nov 2012
Copyright © CodeProject, 1999-2014
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