title: Getting values from a database using a stored procedure?
body: <p>I have a stored procedure for getting last row value of a <code>UserId</code>:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[get_LoginStatusQ]  
      @UserId int
  AS   
  BEGIN  
     SELECT MAX(UserTimeId), LoginStatus 
     FROM UserTime 
     WHERE UserId = @UserId 
     GROUP BY UserId, LoginStatus, Day, HoursWorked, Date, CheckIn,UserTimeId 
  END
  </code></pre>
  
  <p>In C#, I want to get  the value of LoginStatus. How to do I do this?</p>
  
  <p>I tried:</p>
  
  <pre><code>public void GetLogin(object sender, EventArgs e)
  { 
     db.get_LoginStatusQ(Convert.ToInt32(Session["userid"])));
  
     if( LoginStatus ='In') // How do I get the field LoginStatus from the database?
     {
     }
  }
  </code></pre>