Click here to Skip to main content
15,878,945 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day fellow programmers,

Please i can save image to database using the fileUpload control. But my problem is how do i save image in an image control to database.

I want it in a way that when a user is inserting a new post to the database, the pic being displayed with an image control in the user profile will be sent to the pic column in my database.

Please can someone help me out.

Thanks.
Posted
Updated 29-Sep-14 23:13pm
v2

Have you seen this[^] article? It pretty much covers everything you need.
 
Share this answer
 
v2
Hi felix,

there are many articles related this question on web or even on code project, look at the following link, this may help you.

How to retrive an image from sql server[^]
 
Share this answer
 
use this in .cs file for the file uploading and saving into the specific location from where you can retrieve it

if (FileUpload1.HasFile)
{
string filename = TitleBox.Text + (maxid + 1).ToString() + FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath("~/ListingImages/").ToString() + filename);
path = "http://ouronlineneeds.com/ListingImages/" + filename;
}


To show an image use string

string query = "SELECT Title,Logo,Descript,Address,UserName,PhoneNo,MobileNo,EmailID,Website,Confirmed,Keywords FROM Classified WHERE ListID='" + ListId + "'";
DataSet ds = Query.Select(query);
 
Share this answer
 
v2
Thanks a lo for your reply. I really appreciated it!
 
Share this answer
 
Comments
Tomas Takac 30-Nov-14 7:50am    
Please do not post your comments as a solution to your own question. Add comments to the solutions of others instead. And take time to accept the answer which is useful to you, this way you give credit to the person who helped you.

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