当前位置: 代码迷 >> ASP.NET >> 新手了哈 路过的大仙们速来拿分
  详细解决方案

新手了哈 路过的大仙们速来拿分

热度:6385   发布时间:2013-02-26 00:00:00.0
新手弱弱的问了哈 路过的大仙们速来拿分
表Login
userID
userName
userPsw

在第一页中select   userID   from   Login   where   userName=001userPsw=123后
  如何   Session   得到userID的值     这里不会写!!!
然后
Response.Write(第二页)
在第二页中显示除userID的值

多谢大虾们了

------解决方案--------------------------------------------------------
public string xxx() {
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings[ "SQLCONNECTIONSTRING "]);
SqlCommand myCommand = new SqlCommand( "select userID from Login where userName=001 and userPsw=123 ", myConnection);
myConnection.Open();
string zyID=(string)myCommand.ExecuteScalar ();
myConnection.Close();
return zyID;
}

////////////////////////////////////////////////////

Session[ "strxibie "]=类名. xxx() ;


///////////////////
在第二页中直接用一个label.Text=Session[ "strxibie "].ToString();即可
  相关解决方案