title: ASP.NET C# Display address details if logged in
body: <p>On my website i am trying to get my site to display the users address details if they are logged in  have tried a stored procedure:</p>
  
  <pre><code>ALTER PROCEDURE dbo.showAddress
      @userid nvarchar(256)
  AS
      SELECT Fullname, Address, County, Postcode FROM Addresses WHERE @userid = UserId
  RETURN
  </code></pre>
  
  <p>But i get an area about expecting the user id? I have tried inserting through code behind:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (User.Identity.IsAuthenticated)
      {
          SqlCommand oCMD = new SqlCommand();
          SqlConnection oCON = new SqlConnection();
          oCON.ConnectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
          oCON.Open();
          oCMD.Connection = oCON;
          oCMD.CommandType = CommandType.StoredProcedure;
          oCMD.CommandText = "showAddress";
  
          SqlDataReader oRDR = oCMD.ExecuteReader();
          oRDR.Read();
          txtName.Text = oRDR.GetString(oRDR.GetOrdinal("Fullname"));
          oCON.Close();
      }
  }
  </code></pre>
  
  <p>But this doesnt work either for me. Is there some code that could be entered as something like: </p>
  
  <p>txtPostcode.Text = "sql connection; Addresses; Fullname";</p>
  
  <p>Any help or ADVICE is appreciated.... </p>