还有怎样取当前所有用户信息。

解决方案 »

  1.   

    我的程序里的登录的代码
    SqlConnection myConnection = new SqlConnection(ConnectionString); //判断用户输入信息是否正确
    string cmdText = "select UserID from  Users where UserName = '"+LUsersName.Text+"'" ;
    SqlCommand myCommand = new SqlCommand(cmdText,myConnection);
    myConnection.Open();
    SqlDataReader dr=myCommand.ExecuteReader();
    if(!dr.Read())
    {          
    Response.Write("<script>alert(\"此用户名不存在!\")</script>");
    dr.Close();
    }
    else
    {
    dr.Close();
    string cmdText1 = "select UserID from  Users where UserName = '"+LUsersName.Text+"' and  Password ='"+LPassword.Text+"'" ;
    SqlCommand myCommand1 = new SqlCommand(cmdText1,myConnection);

    SqlDataReader dr1=myCommand1.ExecuteReader();
    if(dr1.Read())
    {
    LUsersName.Text = "";
    Session["UserID"] = dr1["UserID"];

    Response.Redirect("Personal.aspx");
    }
    else
    {
    Response.Write("<script>alert(\"密码不正确!\")</script>");
    }  myConnection.Close(); }
      

  2.   

    2 楼正解.用户登录和每次访问的时候将其 id 等基本信息记录进一个 session_online_table, 如果用户下一次访问的时候 session_online_table 中无此用户的记录, 则代表该用户需要重新登录.
      

  3.   

    private void InitializeComponent()
            {
                base.Load += new EventHandler(this.Page_Load);
            }        protected override void OnInit(EventArgs e)
            {
                this.InitializeComponent();
                base.OnInit(e);
            }        private void Page_Load(object sender, EventArgs e)
            {
                base.Application.Lock();
                ArrayList list1 = (ArrayList) base.Application["nstormchatmbms"];
                base.Application.UnLock();
                string[] textArray1 = new string[4];
                textArray1 = (string[]) list1[0];
                string[] textArray2 = new string[9] { "\"", textArray1[0], "|", textArray1[1], "|", textArray1[2], "|", textArray1[3], "\"" } ;
                string text1 = string.Concat(textArray2);
                for (int num1 = 1; num1 < list1.Count; num1++)
                {
                    textArray1 = (string[]) list1[num1];
                    string text3 = text1;
                    string[] textArray3 = new string[10] { text3, ",\"", textArray1[0], "|", textArray1[1], "|", textArray1[2], "|", textArray1[3], "\"" } ;
                    text1 = string.Concat(textArray3);
                }
                string text2 = "";
                text2 = text2 + "<script language=javascript type=text/javascript>\r";
                text2 = text2 + "var mlist=new Array(" + text1 + ");\r";
                text2 = text2 + "parent.nstormchat_memeber=mlist;\r";
                text2 = text2 + "parent.h0.showmemberlist();\r";
                text2 = text2 + "</script>";
                base.Response.Write(text2);
            }