I tried to show the most recent activity performed on user's account but I am getting an error that says:
syntax error near the word 'WHERE'
string connectionString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
using (SqlConnection con = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM ActivityTable ORDER BY ActivityDate DESC WHERE ActivityBy =@ActivityBy", con))
{
cmd.Parameters.AddWithValue("@ActivityBy", byuser.Text.Trim());
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
activitylbl.Text = dr["ActivityDetail"].ToString();
}
else
{
activitylbl.Text = "No activity on this account";
}
con.Close();
}
}