0
{
    public DataTable EmpLoginbyId()
    {
        SqlConnection con = new SqlConnection("server=(local);database=schoolsystem;integrated security=true");
        SqlCommand cmd = new SqlCommand();
        DataTable dt = new DataTable();
        SqlDataAdapter adp = new SqlDataAdapter("EmpLoginbyId", con);
        cmd.CommandType = CommandType.StoredProcedure;
        adp.Fill(dt);
        return dt;
    }
    public void EmpLogin(string Email, String Password)
    {

        SqlConnection con = new SqlConnection("server=(local);database=schoolsystem;integrated security=true");
        SqlCommand cmd = new SqlCommand("EmpLogin", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@Email", Email);
        cmd.Parameters.AddWithValue("@passward", Password);



        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();
    } 

protected void Button1_Click(object sender, EventArgs e) {

        try
        {
            Session["UID"] = Lgn.EmpLogin(TxtUN.Text, TxtPW.Text);
            int? UID = Convert.ToInt32(Session["UID"].ToString());
            DataTable dt = new DataTable();
            dt = Lgn.EmpLoginbyId(Convert.ToInt32(UID));
            string Username = dt.Rows[0]["UserName"].ToString();
            //string Username = dt.Rows[0]["UserName"].ToString();
            Session["ETID"] = Convert.ToInt32(dt.Rows[0]["UserTypeID"].ToString());
            if (Username == null)
            {
                Session["UserName"] = Username.ToString();

            }
            if (UID.HasValue)
            {
                Response.Redirect("Admin.aspx");
            }


        }
        catch { }
    }

and this is my class code it gives me this error Error 1 Cannot implicitly convert type 'void' to 'object'
Error 2 No overload for method 'EmpLoginbyId' takes 1 arguments

0

1 Answer 1

1

First error is there because EmpLogin is returning void and you are trying to assign it to some object which is invalid. So either return some value from the function or remove assignment to session object.

Second error is valid since EmpLoginById doesn't have any parameter in its signature. So either modify signature or call to the function by removing UID.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.