title: Web API to return result from SQL Database
body: <p>I am trying to create a Web API which will get an input and tries to run Select query in SQL Database. The table in the DB has three fields but I need only two fields in the response.Below is the code I am trying</p>
  
  <pre><code>public async Task&lt;IHttpActionResult&gt; Get(string LabName){
  string strcon = ConfigurationManager.ConnectionStrings["CDBConnection"].ConnectionString;
  SqlConnection DbConnection = new SqlConnection(strcon);
  SqlDataReader reader = null;
  DbConnection.Open();
  
  using (SqlCommand command = new SqlCommand("SELECT Acc, CSeq FROM [dbo].[c_Account] WHERE Acc = @AccName", DbConnection))
  {
      command.Parameters.Add(new SqlParameter("AccName", LabName));
      reader = command.ExecuteReader();
      List&lt;QueryResult&gt; qresults = new List&lt;QueryResult&gt;();
  
      while (reader.Read())
      {
          QueryResult qr = new QueryResult();
          qr.AccountID = reader["AccountID"].ToString();
          qr.CounterSeq = ((int)reader["CounterSeq"]).ToString("000");
          qresults.Add(qr);
      }
      DbConnection.Close();
      //build json result
      return Ok(qresults);
  }
  }
  </code></pre>
  
  <p>The issue here is it pulls all the three fields in the response as</p>
  
  <p><code>[{"Acc":"xyz","CSeq":"123","Year":null}]</code></p>
  
  <p>But just expecting the response as </p>
  
  <p><code>[{"Acc":"xyz","CSeq":"123"}]</code></p>
  
  <p>Also is it possible to return the response something like <code>The CSeq associated with Acc xyz is 123</code></p>