How to Retrieve First name and Last name of Manager?

Hi David,

You can use the following code as an example :

    string lastname;
    string firstname;
    string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MainDbSource"].ToString();
  string queryString = "SELECT [LASTNAME],[FIRSTNAME] FROM [USERS] WHERE USERNAME = '" + USERNAME + "'";
  
  using(System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(connectionString))
  {
      System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(queryString, sqlConnection);
      sqlConnection.Open();
        using (System.Data.SqlClient.SqlDataReader reader = command.ExecuteReader())
        {
            while (reader.Read()){
                lastname = reader.GetString(0);
                firstname = reader.GetString(0);
            }
        }
  }
1 Like