Hello,
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)
AS
SELECT Fullname, Address, County, Postcode FROM Addresses WHERE @userid = UserId
RETURN
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;
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();
}
}
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....