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:

ALTER PROCEDURE dbo.showAddress
    @userid nvarchar(256)
    SELECT Fullname, Address, County, Postcode FROM Addresses WHERE @userid = UserId

But i get an area about expecting the user id? I have tried inserting through code behind:

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;
        oCMD.Connection = oCON;
        oCMD.CommandType = CommandType.StoredProcedure;
        oCMD.CommandText = "showAddress";

        SqlDataReader oRDR = oCMD.ExecuteReader();
        txtName.Text = oRDR.GetString(oRDR.GetOrdinal("Fullname"));

But this doesnt work either for me. Is there some code that could be entered as something like:

txtPostcode.Text = "sql connection; Addresses; Fullname";

Any help or ADVICE is appreciated....

I have figured out that my code in fact is working! BUT... The issue seems to be that when a user registers for my site using the CreateUserWizard and this encrypts the username and password, so when my program looks into database for the username it finds the encrypted text and this oviously doesnt match! So i need to either decrypt the code or never encrypt as it goes into databse table! Hmmm...

This question has already been answered. Start a new discussion instead.