Please tell me what I am doing wrong here, I get errors on the Authentice User line 'The best overloaded method match for WClogin.Authenticate User(sting, sting, out int, out char) has some invalid arguments'.
I don't know what should go on the bolded part below. Here is the revised code. Please let me know if I have this setup correctly.
private bool AuthenticateUser(string uname, string password, out int userID, out char type)
{
bool bflag = false;
string strSQL = "select * from WC_users where username ='" + uname + "' AND password ='" + password + "' and auth_type = '" + type + "'";
userID = -1;
type = ;
using (SqlConnection connection = new SqlConnection(queryString))
{
SqlCommand command = new SqlCommand(strSQL, connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
{
// Call Read before accessing data.
if (reader.Read())
{
userID = System.Convert.ToInt32(reader[0]);
bflag = true;
}
// Call Close when done reading.
reader.Close();
}
return bflag;
}
}
protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e)
{
try
{
string uname = Login1.UserName.Trim(); //Get the username from the control
string password = Login1.Password.Trim(); //get the Password from the control
//changed
string type = Label1.Text;
int userID;
bool flag = AuthenticateUser(uname, password, out userID, out type);
if (flag == true)
{
e.Authenticated = true;
//Changed
HttpContext.Current.Session["userID"] = userID;
if (type == "w")
{
}
HttpContext.Current.Session["password"] = password;
Login1.DestinationPageUrl = "reports-maritime.aspx";
if (type == "s")
{
}
HttpContext.Current.Session["password"] = password;
Login1.DestinationPageUrl = "reports-maritime.aspx";
if (type == "a")
{
}
HttpContext.Current.Session["password"] = password;
Login1.DestinationPageUrl = "reports-maritime.aspx";
}
else
e.Authenticated = false;
}
catch (System.Exception)
{
e.Authenticated = false;
}
}