Hi Every one,
Here Iam creating Two tables in sql server when student click the submit button check the user crendtials in first table and when admin click the check the Admin Credtinals .so here iam writing Code is perfectly working but i dont know how to insert the if statement . ....... any one let me where i do wrong in my code...
protected void BtnSubmit_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=SERVER;Initial Catalog=MuraliIIT;User ID=sa;Password=rits@1234");
SqlCommand cmd = new SqlCommand("select COUNT(*)FROM NewStudentRegistrationForm WHERE UserName='" + TxtUserName.Text + "' and password='" + Txtpassword.Text + "' and ApproveStatus=1");
cmd.Connection = conn;
conn.Open();
int OBJ = Convert.ToInt32(cmd.ExecuteScalar());
if (OBJ > 0)
{
Session["UserName"] = TxtUserName.Text;
// Response.Write("password is correct");
TxtUserName.Text = "";
Response.Flush();
Response.Redirect("StudentLoginSuccessfully.aspx");
}
else
{
Response.Write("");
}
}
SqlConnection conn1 = new SqlConnection("Data Source=SERVER;Initial Catalog=MuraliIIT;User ID=sa;Password=rits@1234");
SqlCommand cmd1 = new SqlCommand("select COUNT(*)FROM Admin WHERE UserName='" + TxtUserName.Text + "' and password='" + Txtpassword.Text + "'");
cmd1.Connection = conn1;
conn1.Open();
int OBJ1 = Convert.ToInt32(cmd1.ExecuteScalar());
if (OBJ1 > 0)
{
Session["UserName"] = TxtUserName.Text;
// Response.Redirect("AdminAcceptstudents.aspx");
Response.Redirect("AdminAcceptstudents.aspx");
TxtUserName.Text = "";
}
}

Manoj BhoirPosted May 26, 2015, 10:48 AM
Manoj BhoirPosted May 26, 2015, 11:12 AM
Venkata SubbareddyPosted May 26, 2015, 11:11 AM