Hi
I have a login Page where i want the Faculty to login and on the next page which is "Welcome_Faculty" i want to display a label showing " Welcome Faculty_Name" from the below table in Sql server.The Table is shown below. Faculty_Name UserName PasswordElena Popel epopel popelRaied Salman rsalman salman
Ravi Rathnam rrathnam rathnam
the code which i have for Login page is as follows
public partial class Faculty_Login : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) {
} protected void BtnLogin_Click(object sender, EventArgs e) { string strcon = ConfigurationManager.ConnectionStrings["MyDatabaseConnection"].ConnectionString;
SqlConnection con = new SqlConnection(strcon);
SqlCommand com = new SqlCommand("CheckFaculty", con);
com.CommandType = CommandType.StoredProcedure;
SqlParameter p1 = new SqlParameter("username", TextBox1.Text);
SqlParameter p2 = new SqlParameter("password", TextBox2.Text);
com.Parameters.Add(p1);
com.Parameters.Add(p2); con.Open();
SqlDataReader rd = com.ExecuteReader();
if (rd.HasRows) {
rd.Read(); Session["username"]= TextBox1.Text; // Label5.Text = "Login successful."; Response.Redirect("Welcome_Faculty.aspx"); }
else {
Label5.Text = "Invalid username or password.";
} }}
The login page is Working perfect but when i go on the next page i want to display a label which picks the faculty_name from the above table corresponding to the username and password .How can i do that Can somebody help me with this?