在我的网站上,我试图让我的网站显示用户的地址详细信息,如果他们登录已经尝试了一个存储过程:
ALTER PROCEDURE dbo.showAddress
@userid nvarchar(256)
AS
SELECT Fullname, Address, County, Postcode FROM Addresses WHERE @userid = UserId
RETURN
但我得到了一个关于期待用户 ID 的区域?我尝试通过后面的代码插入:
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();
}
}
但这对我也不起作用。是否有一些代码可以输入如下:
txtPostcode.Text = "sql 连接;地址;全名";
任何帮助或建议表示赞赏....