Click here to Skip to main content
14,661,175 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have upload a image file using below code and the image is saving in Image folder and its data store in Image data type is <binary data=""> w.r.t ID and Name (i.e user name)

I want to retrieve that image and show on grid view, or you can say like when the use login his pic is displayed after login need help ..... need

 protected void Button2_Click(object sender, EventArgs e)

            TextBox2.Text = Label3.Text;
            string path = Server.MapPath("Images/");
            MyConn.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database.mdf;Integrated Security=True;User Instance=True";

            if (FileUpload1.HasFile)
                string ext = Path.GetExtension(FileUpload1.FileName);
                if (ext == ".jpg" || ext == ".png")
                    FileUpload1.SaveAs(path + FileUpload1.FileName);
                    string name = "~/images/" + FileUpload1.FileName;
                    string s = "insert into upload values ('" + TextBox1.Text + "', '" + TextBox2.Text + "', '" + name + "')";

                    MyComm = new SqlCommand(s, MyConn);

                    Response.Write("Your file has been uploaded");

                    Response.Write("You can only upload jpg or png file");

                Response.Write(" Please select a file");


        catch { }
Updated 6-Nov-12 18:27pm
ridoy 7-Nov-12 0:20am
please retag it,it's should not be under codeproject tag..
MT_ 7-Nov-12 0:24am
Agree with Ridoy. re-tag to get attention.

1 solution

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100