i want to retrieve student ID from database after login ,below is code where i am login from student name and password,but i want to retrieve id after login into session.
protected void b1_Click(object sender, EventArgs e)
{
int i = 0;
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select * from tbl_student where S_Name='" + username.Text + "' and t_Pwd= '" + password.Text + "' ";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
i = Convert.ToInt32(dt.Rows.Count.ToString());
if (i > 0)
{
Session["student"] = username.Text;
Response.Redirect("issue_std_Books.aspx");
}
else
{
error.Style.Add("display", "block");
}
}
here i want student id not name
Session["student"] = username.Text;
Response.Redirect("issue_std_Books.aspx");