how can i insert an image into sql database and than i can i retrieve it.
i want to create an asp.net application where a student add his/her image on registration page and this image save in sql datatable and further we can use this image on other pages as required.
Loading

Deepak Kumar ChoudharyRank #4,523 · 339 reputationPosted Feb 28, 2014, 7:42 AM EST
imgeurl is a table column name
I am also attached your same website file with correction now execute
Deepak Kumar ChoudharyRank #4,523 · 339 reputationPosted Feb 27, 2014, 6:35 AM EST
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=xyz;Integrated Security=True");
con.Open();
string fpath = "\\uploads\\" + FileUpload1.FileName.ToString(); FileUpload1.PostedFile.SaveAs(Server.MapPath(fpath));
Session["user"] = TextBox1.Text;
SqlCommand cmd = new SqlCommand("insert into reg values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + fpath + "'", con); cmd.ExecuteNonQuery();
Response.Redirect("ViewProfile.aspx");
2.Now access image form database using flowing code
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=xyz;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand("select * from reg where userid='"+Session["user"].ToString()+"'", con);
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
Image1.ImageUrl = dr["imageurl"].ToString();
Nitin Sharma152 reputationPosted Feb 28, 2014, 12:39 AM EST
i m attaching the source code with sql query page please check it and advice me how to do it
thanks in advance.
Nitin Sharma152 reputationPosted Feb 28, 2014, 7:38 PM EST
thank you very much for your help