I'm trying to display the SQL query result in a label but it's not showing. The user picks a value from the dropdown list and the label should populate the result. a This is my code:
protected void drpEmployeeName_SelectedIndexChanged(object sender, EventArgs e)
{
String connString = ConfigurationManager.ConnectionStrings["HRPlannerConnectionString1"].ConnectionString;
SqlConnection conn = new SqlConnection(connString);
string result = "SELECT EmployeeName from Employees WHERE EmployeeID= '" + drpEmployeeName.SelectedItem.Value + "'";
SqlCommand showresult = new SqlCommand(result, conn);
conn.Open();
lblEmployee.Text = showresult.ExecuteScalar().ToString();
conn.Close();
}
Please help!