1
我與C#的工作,在VS 2008,框架3.5,我需要保存的用戶名和時 用戶登錄,就說明他/她的第一個和最後一個名字,在這點可以保存它, 這就是我想要的,但需要展示給用戶的不是他/她的用戶名就在上述第 姓氏。這裏是我的代碼,在此先感謝。保存用戶名,但給出了C#的名字
//code in the login
ClPersona login = new ClPersona();
bool isAuthenticated = login.sqlLogin1((txtUsuario.Text), (txtPassword.Text));
if (isAuthenticated)
{
Session["sesionicontrol"] = login.NombreUsuario;
Response.Redirect("../MENU/menu1.aspx");
}
//code in the form where shows the username but I want the first and last name
public partial class menu2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblNombreUsuario.Text = (string)Session["sesionicontrol"];
if (!IsPostBack)
//ClPersona class
public Boolean sqlLogin1(string nombreUsuario, string password)
{
string stSql = "select * from usuarios where usuario='" + nombreUsuario + "' and
pass='" + password + "'and id_rol='1'";
Bd miBd = new Bd();
DataTable dt = miBd.sqlSelect(stSql);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
//return ds;
if (dt.Rows.Count > 0)
{
return true;
}
else
{
return false;
}
}
是否'login'對象檢索姓和名,可以是提供接入性能存儲在會話中? – mellamokb
@mellamokb沒有,問題是,我需要保存的用戶名在我的數據庫,但用戶必須看到他/她的名字和姓氏不是他/她的用戶名,在此先感謝 – suely
請出示sqlLogin1方法和ClPersona類 – Reniuz