Click here to Skip to main content
15,905,963 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
public UserAcct(string name, string password)
{
string conString = WebConfigurationManager.ConnectionStrings
["StoreConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(conString);
SqlCommand cmd = new SqlCommand("Select User ID, Role, Email from [Users] where name = @name and PWDCOMPARE(@password, password = 1", con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@name", name);
cmd.Parameters.AddWithValue("@password", password);
con.Open();

SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.HasRows)
{
sdr.Read();
this.UserId = (int)sdr[0];
this.Name = name;
this.Role = (string)sdr[1];
this.Email = (string)sdr[2];

//Session["User"] = this;
//if (this.Role == "user")
// Session["Cart"] = new ShoppingCart();
}
else
{
this.UserId = 0;
}
con.Close();
}

What I have tried:

I haven't tried anything other than googling the problem, I don't know where to start.
Posted
Updated 12-Dec-16 5:42am
Comments
Philippe Mori 12-Dec-16 16:34pm    
Are you too lazy to format your code?

Missing close bracket:
SQL
... name = @name and PWDCOMPARE(@password, password = 1", con);

Try:
SQL
... name = @name and PWDCOMPARE(@password, password) = 1", con);
 
Share this answer
 
Closing parenthesis it missing here:
PWDCOMPARE(@password, password = 1"

PWDCOMPARE (Transact-SQL)[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900