lekhanhvinh 0 Newbie Poster

I would like to get information of an employee by his EmployeeKey - in my case : LastName, FirstName, Gender, and Title using ASP. Net - C# - then display this information to label (label.Text = return value)

The SQL is simple -

use AdventureWorksDW SELECT [FirstName], [LastName],[Gender], [Title] FROM [DimEmployee] WHERE ([EmployeeKey] = @Employeekey)

Tested and Worked

public static SqlDataReader getEmployeeInformation(int employeeID)
    {
        string sql = "use AdventureWorksDW SELECT [FirstName], [LastName],[Gender], [Title] FROM [DimEmployee] WHERE ([EmployeeKey] = "  + employeeID + ")";
        SqlConnection connection = connectionManager.GetOTMC_HR();

        SqlCommand command = new SqlCommand(sql, connection);
        command.CommandType = CommandType.Text;

        SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection | CommandBehavior.SingleResult);

        return reader;

    }
    }
protected void Button1_Click(object sender, EventArgs e)
    {

                string trash = employeeIDSelection.Text;
                int employeeIDD = int.Parse(trash);
                using (SqlDataReader reader = getEmployee.getEmployeeInformation(employeeIDD))
                {
                    while (reader.Read())
                    {
                        ///use AdventureWorksDW SELECT [FirstName], [LastName],[Gender], [Title] FROM [DimEmployee] WHERE ([EmployeeKey] = employeeIDSelection.TexT)
                        ///
                        string employeeFirstName = reader.GetString(0);
                        string employeeLastName = reader.GetString(1);
                        string employeeGender = reader.GetString(2);
                        string employeeTitle = reader.GetString(3);
                        lbEmployeeName.Text = employeeLastName + "," + employeeFirstName;
                        lbTitle.Text = employeeTitle;
                    }
                    reader.Close();
                }

                }

When I run it, there is no error but nothing display. I assume that there is no return values or the values are clear after return but I cannot find the solution. Any help would be appreciated.

Ops - I think this should be posted in ASP section