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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void 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");
}
}
private bool SiteLevelCustomAutheticationMethod (string UserName, string Password)
{
bool boolReturnValue = false;
string scon = "SERVER=.; INITIAL CATALOG=Villaplus; UID=sa; PWD=ash; ";
SqlConnection con = new SqlConnection(scon);
String strSQL = "Select * From Login";
SqlCommand com = new SqlCommand(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.