日期:2014-05-19  浏览次数:20456 次

新手弱弱的问了哈 路过的大仙们速来拿分
表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();即可