我有一個註冊和登錄系統,我需要從SQL數據庫調用名稱變量。我需要一個歡迎信息。如何從SQL數據庫「調用」值?
label2.Text = "Welcome!" + nameFromDatabase;
如何從數據庫中檢索名稱值?
我有一個註冊和登錄系統,我需要從SQL數據庫調用名稱變量。我需要一個歡迎信息。如何從SQL數據庫「調用」值?
label2.Text = "Welcome!" + nameFromDatabase;
如何從數據庫中檢索名稱值?
如果您在網站上使用ASP.NET membership
,則可以顯示當前用戶username
在用戶登錄,請參閱下面的代碼: - 。
protected void Page_Load(object sender, EventArgs e)
{
// First find if user is logged in
if (Context.User.Identity.IsAuthenticated)
{
// Finds user name and says Welcome
lblWelcome.Text = "Welcome " + Context.User.Identity.Name;
}
else
{
// It is anonymous user, say Welcome to guest
lblWelcome.Text = "Welcome guest";
}
}
另一種方式是把用戶名在Session
和通過使用標籤顯示它
lblWelcome.Text = "Welcome " + Session["UserName"].ToString();
發佈您的嘗試代碼 –
我們不會給你所有的書面代碼。嘗試從[這裏](http://stackoverflow.com/questions/27043733/welcome-message-on-master-page-after-login)如果你卡住任何地方,然後張貼問題 – BNN
我只需要一個代碼是什麼從sql數據庫中調用標籤消息的值 – CoopCky