You need to fill the records in a SqlDatareader or a DataSet/DataTable using SqlDataAdapter. Currently you are using ExecuteNonQuery which is usually used for INSERT/UPDATE statements.
DataTable dt = new DataTable();
using (SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("SELECT something FROM table"))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
}
}
This would return your results from your query in DataTable.
If you want to get the results back in a List<string> (since you are requesting a single column from your table and chances are there would be multiple rows) you can do:
List<string> returnedList = new List<string>();
using (SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("SELECT something FROM table"))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
connection.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
returnedList.Add(Convert.ToString(reader["something"]));
}
}
}
}
Then to get a single string you can do:
string singleString = string.Join(Environment.NewLine, returnedList);