Try this I've already implemented this
public bool login(string id, string entered_password)
{
public SqlConnection con = new SqlConnection("Data Source=[Server Name];Initial Catalog=[Database Name];User ID=[User];Password=[Password]");
con.Open();
string query = "SELECT [userpass] FROM userlogin WHERE [userid]=@id";
SqlCommand cmdChk = new SqlCommand(query, con);
cmdChk.Parameters.Add("@id", SqlDbType.VarChar).Value = id;
SqlDataReader dr = cmdChk.ExecuteReader();
int count = 0;
string password = "";
while (dr.Read())
{
count++;
password= dr[0].ToString();
}
dr.Close();
con.Close();
if (count < 1)
{
return false;
}
else
{
if (password == entered_password)
{
return true;
}
else
{
return false;
}
}
}