Updated Solution-
Change Your SP as Follows-
ALTER procedure [dbo].[splogin2]
@UserName nvarchar(50),
@Password nvarchar(50)
as
If exists(select Users.UserID from [Users] where UserName=@UserName and
Password=@Password
and UserTypeID=1 ) select 1
If exists(select Users.UserID from [Users] where UserName=@UserName and
Password=@Password
and UserTypeID=2 ) select 2
Change the Function for the login User as-
public int Loginuser(string UserName, string Password)
{
return db.ExecuteDataSet("splogin2", new object[] { UserName, Password }).Tables[0].Rows[0][1].ToString())
}
Alter your button Click as-
protected void Button1_Click(object sender, EventArgs e)
{
if (cd.Loginuser(UserName.Text, Password.Text)==1)
{
Session["UserID2"] = cd.Loginuser(UserName.Text, Password.Text);
Session["Login4"] = UserName.Text;
Session["Login5"] = Password.Text;
Lgin.Text = ("Login Successfully");
Response.Redirect("WebForm1.aspx");
Lgin.Text = ("Incorrect Passsword");
}
else if (cd.Loginuser(UserName.Text, Password.Text)==2)
{
Session["UserID"] = cd.Loginuser(UserName.Text, Password.Text);
Session["Login2"] = UserName.Text;
Session["Login3"] = Password.Text;
Lgin.Text = ("Login Successfully");
Response.Redirect("Home.aspx");
Lgin.Text = ("Incorrect Passsword");
}
}