Click here to Skip to main content
15,898,010 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to display an image on a C# form using its path which is saved in SQL database.
First I saved the path of the image in SQL database.
C#
//upload
// open file dialog 
   OpenFileDialog open = new OpenFileDialog();

// image file path
   lblPicture.Text = open.FileName;

//save
Personal person = new Personal();

  var
  _with1 = person;
  _with1.myPicture = lblPicture.Text; 

Now I want to display this image on a C# form using its path which is saved in SQL database when a search button is clicked. I tried this but given an error.
C#
//search button
     string filePath = person.myPicture.ToString();
     Image newImage = Image.FromFile(filePath);

_with3.imgPerson.Image = newImage;

Help needed please.
Posted
Updated 27-Feb-12 1:06am
v3
Comments
V. 27-Feb-12 6:59am    
It is very unclear what you're trying to achieve. Did the save succeed? Did you read correctly from the database? is the path correct? (\ characters escaped?)When you put a breakpoint on Image newImage = Image.FromFile(filePath);
what does filepath contain and does the file exist?
André Kraak 27-Feb-12 7:07am    
Edited question:
Added pre tags
Formatted text/code
Sergey Alexandrovich Kryukov 28-Feb-12 0:15am    
What do you want to do with this picture?
--SA

1 solution

check this links from CodeProject

How to Load/Display images with C#[^]

A Simple Image Slide Show[^]

Hope this will help you
 
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