cmd.Parameters.Add("@PWD",SqlDbType.VarChar,20); cmd.Parameters["@ID"].Value=txtName.Text; cmd.Parameters["@PWD"].Value=txtPwd.Text; conn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { if(dr.Read()) { bool NotOL=true; for(int i=0;i<Application.Count;i++) { if(Application[Application.GetKey(i).ToString()].ToString()==dr["UserID"].ToString()) NotOL=false; } if(NotOL) { Application[Session.SessionID.ToString()]=dr["UserID"].ToString(); Application["OL_UserCount"]=(int)Application["OL_UserCount"]+1; Session["UserName"]=dr["UserName"].ToString();//Sessions Response.Redirect("./main/main.aspx");
} else message.Text="已经登陆"; } |