how to check userid and password from database.i have to open a page of teacher,admin,parent through switch case my code is here:................ using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; using System.Configuration; public partial class _Default : System.Web.UI.Page { SqlConnection con; SqlDataReader dr; SqlDataReader dr1,dr2; SqlDataAdapter da; SqlCommand sqlcomm; string username; string password; protected void Page_Load(object sender, EventArgs e) { string str = (string)ConfigurationManager.AppSettings["connectionstring"]; con = new SqlConnection(str); } protected void Button1_Click(object sender, EventArgs e) { con.Open(); string s=selected(DropDownList1.SelectedValue); string p="select username,password from login where type="+ s +""; sqlcomm = new SqlCommand(p,con); dr=sqlcomm.ExecuteReader(); if (dr.Read()) { username = dr1.GetString(0); password = dr2.GetString(1); if ((TextBox0.Text == username)&&(TextBox1.Text==password)) { Server.Transfer("Admin.aspx"); switch () { case "Admin": return "Admin.aspx"; case "Parent": return "Parent.aspx"; case "Teacher": return "Teacher.aspx"; default: return "zero"; } } \ } } public string selected(string i) { switch (i) { case "Admin": return "Admin"; case "Parent": return "Parent"; case "Teacher": return "Teacher"; default : return "zero"; } } }
if ((TextBox0.Text == username)&&(TextBox1.Text==password)) { switch (s) { case "Admin": Server.Transfer("Admin.aspx"); case "Parent": Server.Transfer("Parent.aspx"); case "Teacher": Server.Transfer("Teacher.aspx"); default: return "zero"; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)