protected void LoginButton_Click(object sender, EventArgs e)
        {  
           ///以下strsql可防止SQL注入
           strsql = "select count(1) as Num from employee where Pernr='"+this.Login1.UserName.Trim()+"' and Password='"+this.Login1.Password.Trim()+"'";
           dt = cf.GetTable(strsql);
           if (Convert.ToInt32(dt.Rows[0]["Num"]) > 0)
           {
               strsql2 = "select distinct STAT2,PERSA from ZTA_HRDNET where pernr = '" + this.Login1.UserName.Trim() + "'";  ////验证用户是否在职
               dt1 = cf.GetTable(strsql2);
               string stat = dt1.Rows[0]["STAT2"].ToString().Trim();     ////在职状态的判断.
               string persa = dt1.Rows[0]["PERSA"].ToString().Trim();    //////人事范围的判定.
               if (stat == "3")
               {
                   urkey = this.Login1.UserName.ToString();              ////获取用户账号
                   password = this.Login1.Password.ToString().Trim();    ////获取用户密码
                   if (persa == "2222")                                  ////获取用户人事范围.
                       Server.Transfer("Admin/AdminDefault.aspx?flag=1", true);////带参数flag来指定login传来值.
                   else
                       Server.Transfer("Default.aspx?flag=2", true);////带参数flag来指定login传来值.
               }
               else
               {
                   cf.Alert("用户账号已停用!", Page);
               }
           }
           else
           {
               ////this.Page.ClientScript.RegisterStartupScript(this.GetType(), "long", "alert('用户名或密码错误')", true);
               //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('用户账号已停用!')", true);
               Page.RegisterStartupScript("s", "<script language='javascript'>alert('Sorry,用户名或密码错误!')</script>");
           }
        }当用户密码正常时,是进入系统是OK的.当用户密码不正确时,下面三个弹出对话框程序都可以执行通过,就是弹不出对话框来,这个是不是login控制的原因.
               ////this.Page.ClientScript.RegisterStartupScript(this.GetType(), "long", "alert('用户名或密码错误')", true);
               //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('用户账号已停用!')", true);
               Page.RegisterStartupScript("s", "<script language='javascript'>alert('Sorry,用户名或密码错误!')</script>");报出错误:
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: SQL 网络接口, error: 26 - 定位指定的服务器/实例时出错)