Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • renjithgk
    New Member
    • May 2007
    • 1

    #1

    Error

    hi all this is my code i am posting i m getting 2 errors Cannot implictly convert string to bool and bool to string

    protected void Login1_Authenti cate(object sender, AuthenticateEve ntArgs e)
    {
    bool Authenticated=f alse;
    Authenticated = VerifyPassword( Login1.UserName ,Login1.Passwor d);
    e.Authenticated = Authenticated;
    if (Authenticated == true)
    {
    Response.Redire ct ("Datademo.aspx ");
    }
    }
    private string VerifyPassword( string UserName,string Password)
    {
    bool passwordMatch = false;
    string con="Data Source=MLBMYSFF 02\\SQLEXPRESS; database=Renjit h;uid=renjith;p wd=abc;";
    SqlConnection conn = new SqlConnection(c on);
    string sql = "Select * From InfoTab";
    SqlCommand cmd = new SqlCommand(sql, conn);
    SqlDataReader dr;
    conn.Open();
    dr = cmd.ExecuteRead er();
    while (dr.Read())
    {
    if ((Login1.UserNa me == dr["Username"].ToString())&(L ogin1.Password == dr["Password"].ToString()))
    {
    passwordMatch = true;
    }

    }
    dr.Close();
    return passwordMatch;
    }
    }

    pls reply can anyone help
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    I would suggest debugging starting with line bool Authenticated=f alse;.

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Your function returns a STRING value which you are trying to assign to a BOOL datatype.
      Change your function to return type "bool" or changed your Authenticated variable to "string" type and make other changes to support the string.

      Based on how you coded your function I would change this:
      Code:
      private string VerifyPassword(string UserName,string Password)
      to
      Code:
      private bool VerifyPassword(string UserName,string Password)

      Comment

      Working...