See The Below Code To Insert Session into
Uploaded Image:
con.Open();
if (FileUpload1.HasFile)
{
string fpath;
fpath =
"~/regphoto/" + FileUpload1.FileName;
string sql = "insert
into reg values('" + TextBox1.Text + "','"
+ TextBox2.Text + "','" + TextBox3.Text +
"','" + TextBox4.Text +
"','" + TextBox5.Text +
"','" + TextBox6.Text +
"','" + fpath +
"')";
SqlCommand cmd =
new SqlCommand(sql, con);
int i = cmd.ExecuteNonQuery();
if (i < 0)
{
FileUpload1.SaveAs(Server.MapPath(fpath));
Session["upphoto"]
= fpath.ToString();
}
}
con.Close();
If u want to insert session into Database
table Column by using ExecuteReader() then :
con.Open();
string str = "select
* from reg where Email='" + TextBox1.Text + "' and pass='" + TextBox2.Text + "'";
SqlCommand cmd =
new SqlCommand(str, con);
SqlDataReader dr =
cmd.ExecuteReader();
if (dr.Read() == true)
{
Session["uname"]
= dr[0].ToString();
Session["upphoto"]
= dr[6].ToString(); //where [6]
is number of Column in Database Table.
Response.Redirect("Home.aspx");
}
else
{
Label4.Text =
"Incorrect Email ID or Password !!!";
}
con.Close();