title: How should I get the values from the select query of the stored procedure in c#
body: <p>I want the date and the name from the select query which if I run as normal query I get the results but i when I try to get the results in C# all I get is <code>count=0</code>. Can anyone tell me what wrong am I doing?</p>
  <p>Here is the C# code</p>
  <pre><code>private List&lt;CertificationSummary&gt; GetLastAccessData (string taskOwner)
  {
      List&lt;CertificationSummary&gt; lastAccessedResult = new List&lt;CertificationSummary&gt;();
  
      string connectionString = SqlPlusHelper.GetConnectionStringByName(&quot;MetricRepositoryDefault&quot;);
  
      using (SqlConnection connection = new SqlConnection(connectionString))
      {
          SqlParameter[] sqlParams = new SqlParameter[1];
          sqlParams[0] = new SqlParameter(&quot;@taskOwner&quot;, SqlDbType.NVarChar);
          sqlParams[0].Value = taskOwner;
  
          connection.Open();
  
          SqlCommand cmd = connection.CreateCommand();
          cmd.CommandType = CommandType.StoredProcedure;
          cmd.CommandText = &quot;GetLastAccessedCertificationData&quot;;
  
          cmd.Parameters.AddRange(sqlParams);
  
          cmd.ExecuteNonQuery();
      }
  
      return lastAccessedResult;
  }
  </code></pre>
  <p>And here is the stored procedure:</p>
  <pre><code>SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  
  ALTER PROCEDURE [dbo].[GetLastAccessedCertificationData]
      (@taskOwner nvarchar(255))
  AS
  BEGIN
      DECLARE @name nvarchar(100)
      DECLARE @lastAccessedDate [datetime] 
  
      SELECT @name = Name 
      FROM CertificationReviewCycles 
      INNER JOIN UserReviewCycleAccess ON CertificationReviewCycles.CertificationReviewCycleID = UserReviewCycleAccess.LastAccessedReviewCycleID 
      WHERE USERID = @taskOwner
  
      SELECT @lastAccessedDate = LastAccessedDate 
      FROM UserReviewCycleAccess 
      WHERE UserID = @taskOwner
  
      CREATE TABLE #tempTable
      (
           name [nvarchar](255) NULL, 
           [LastAccessedDate] [datetime] NULL,
      )
  
      INSERT INTO #tempTable VALUES (@name, @lastAccessedDate)
  
      SELECT TOP(1) name, LastAccessedDate 
      FROM #tempTable
  END
  GO
  </code></pre>