solution for not all code paths return a value for bool
Expand Post »
i have creted this code for login control:
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; publicpartialclass_Default : System.Web.UI.Page
{ protectedvoid Page_Load(object sender, EventArgs e)
{
} protectedvoid Login1_Authenticate(object sender, AuthenticateEventArgs e)
{ bool Autheticated = false;
Autheticated = SiteLevelCustomAutheticationMethod(Login1.UserName, Login1.Password);
e.Authenticated = Autheticated; if (Autheticated == true)
{
Response.Write("Home.aspx");
}
} privatebool SiteLevelCustomAutheticationMethod (string UserName, string Password)
{ bool boolReturnValue = false; string scon = "SERVER=.; INITIAL CATALOG=Villaplus; UID=sa; PWD=ash; "; SqlConnection con = newSqlConnection(scon); String strSQL = "Select * From Login"; SqlCommand com = newSqlCommand(strSQL, con); SqlDataReader Dr;
con.Open();
Dr = com.ExecuteReader(); while (Dr.Read())
{ if ((UserName == Dr["name"].ToString()) & (Password == Dr["Password"].ToString()))
{
boolReturnValue = true;
}
Dr.Close();
return boolReturnValue;
}
}
}
but it gives error:
'_Default.SiteLevelCustomAutheticationMethod(string, string)': not all code paths return a value .
please give solution for this.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.