I know this isn't much of a question, but its kind of last minute.
I am uploading an image from website and saving its path in the databse and the image in the images folder in the project. But the image is not being displayed when I assign the path in the databse in the image url and my datalist image.
Here is the required code :
SqlCommand cmd3 = new SqlCommand();
cmd3.Connection = con;
cmd3.CommandText = "insert into prod_details(prod_img,etc) values(@img,etc)";
string filename = Path.GetFileName(FileUpload1.FileName);
FileUpload1.SaveAs(Server.MapPath("~/images/") + filename);
string sp = Server.MapPath("~/images/") + filename;
cmd3.Parameters.Add(new SqlParameter("@img", sp));
cmd3.ExecuteNonQuery();
The path being saved in the databse is :
C:\Users\PRANJAL\documents\visual studio 2010\WebSites\test\images\2.jpg
And this is how I am trying to bind this path with the image.
cmd1.CommandText ="select prod_img,etc from prod_details";
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
Image1.ImageUrl = dr[0].ToString();
}
Can you please tell me what I am doin wrong?
I have an idea that the slases "/" are not exactly right. How can i chage that and get the image to display?