hi, iam using asp.net with c#
i have table images
shop nvarchar(50),
imgc image
imgo image
iam saving images in a database but while retreving it is showing blank images. i want to display as thumb nail images ,
can you correct my code which helps me
saving code
======== protected void Button1_Click(object sender, EventArgs e) { if (FileUpload1.HasFile && FileUpload2.HasFile) { img1.ImageUrl = imgc.ImageUrl; img2.ImageUrl = imgo.ImageUrl; FileUpload1.SaveAs(MapPath("~/images/" + FileUpload1.FileName)); imgc.ImageUrl = "~/images/" + FileUpload1.FileName; FileUpload2.SaveAs(MapPath("~/images/" + FileUpload2.FileName)); imgo.ImageUrl = "~/images/" + FileUpload2.FileName; con.Open(); SqlCommand cmd = new SqlCommand("Addimgproc",con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Shop","Alsafa"); FileInfo imageinfo = new FileInfo(FileUpload1.PostedFile.FileName.Trim()); byte[] content = new byte[imageinfo.Length]; FileStream imagestream = imageinfo.OpenRead(); imagestream.Read(content,0,content.Length); imagestream.Close(); //2nd upload FileInfo imageinfo1 = new FileInfo(FileUpload2.PostedFile.FileName.Trim()); byte[] content1 = new byte[imageinfo1.Length]; FileStream imagestream1 = imageinfo1.OpenRead(); imagestream1.Read(content1, 0, content1.Length); imagestream1.Close(); cmd.Parameters.AddWithValue("@imgc", content); cmd.Parameters.AddWithValue("@imgo",content1); cmd.ExecuteNonQuery(); con.Close(); } }
retreving code:
==============
protected void Page_Load(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("select imgc,imgo from images where Shop='Alsafa'",con); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { Image1.ImageUrl = dr["imgc"].ToString(); Image2.ImageUrl = dr["imgo"].ToString(); } dr.Close(); } con.Close(); }