Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi friends

i am inserting my friends image in my sql database and now i want to retrieve image from database base and save it to my local drive but i am unable to o it please help me.
C#
try
            {
                String sql = "Select name, Image from ImageTest";
                DataTable dt = new DataTable();
                _Connection.FillTable(ref dt, sql);
                Image img = null;
                for (int i = 0; i <= dt.Rows.Count - 1; i++)
                {
                    string TempPath;
                    TempPath = System.IO.Path.GetTempPath() + "\\myImage.jpeg";
                    img = _Connection.RetriveImageFromDB(dt.Rows[i][1]);
                    img.Save(System.IO.Path.GetTempPath() + "\\myImage.jpeg", ImageFormat.Jpeg);                  
                  
                }
            }

            catch { }

my code is not working and i get a error "A generic error occurred in GDI+"
Posted
Updated 15-Dec-11 18:18pm
v2
Comments
AmitGajjar 16-Dec-11 0:55am    
Use BitMap class for storing your image on local computer..
Tiwari A K 16-Dec-11 4:00am    
Thanks

i was try Bitmap class but not succeed. But now i get different type of solution for my problem. Thanks again.
AmitGajjar 16-Dec-11 4:02am    
Also post your answer so that other people can save their time from your solution...

1 solution

Have you tried using a datareader, temporary storing the data in a general object and then casting it into an Image object? saving it to a fixed destination (C:/)?
just to try.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900