title: Assign value from stored procedure to a variable
body: <p>I'm using stored procedure to get the 'password' value from the database. and i need to assign this value to a variable. I'm using <code>asp.net- mvc</code> and <code>Ado.net</code>.
  Here is my stored procedure.</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[getPassword]
  (
  @Email VARCHAR(100)
  )
  AS
  BEGIN
  SELECT Password FROM dbo.Staff_Login WHERE Email=@Email
  END
  </code></pre>
  
  <p>Here is my repository class.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Configuration;
  using System.Data;
  using System.Data.SqlClient;
  using System.Linq;
  
  namespace Job_Recuitment_System.Repository
  {
      public class LoginRepository
      {
          private SqlConnection con;
          //To handle sql connection
          private void connection() {
              string constr = ConfigurationManager.ConnectionStrings["mycon"].ToString();
              con = new SqlConnection(constr);
          }
  
          //to get the password
          public List&lt;StaffLogin&gt; getPassword(StaffLogin obj) {
              connection();
              List&lt;StaffLogin&gt; pword = new List&lt;StaffLogin&gt;();
              SqlCommand com = new SqlCommand("getPassword", con);
              com.CommandType = CommandType.StoredProcedure;
              com.Parameters.AddWithValue("@Email",obj.Email);
              SqlDataAdapter da = new SqlDataAdapter(com);
              DataTable dt = new DataTable();
              con.Open();
              da.Fill(dt);
              con.Close();
  
              //Bind StaffLogin 
              pword = (from DataRow dr in dt.Rows
  
                         select new StaffLogin()
                         {
                             Password = Convert.ToString(dr["Password"]),
                         }).ToList();
  
  
              return pword;
  
          }
  
      }
  }
  </code></pre>
  
  <p>I have use a list. But i need to assign value to a varible. because i only i need is one value (password).</p>