SqlConnection conn = new SqlConnection("server=.;uid=sa;pwd=sa;database=qcyy");

        if (conn.State != ConnectionState.Open)
        {
            conn.Open();
        }
        SqlDataAdapter da = new SqlDataAdapter("select * from qcyy where name='" + name +

      "' and pasword='" +pasword+ "'", conn);

        DataSet ds = new DataSet();
        da.Fill(ds);
        conn.Close();
        if (ds.Tables[0].Rows.Count > 0)
        {
            Session["name"] = name;
            Session["name"] = ds.Tables[0].Rows[0]["name"].ToString();
            Session["pasword"] = ds.Tables[0].Rows[0]["pasword"].ToString();
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('

登陆成功!');location.href='index.aspx';</script>");
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('

登陆失败!');</script>");

        }




[b]<%if (Session["name"] == null)
      { %>[/b]          <div id ="zhuce" style="background-image: url('imges/2.png'); width :180px; height :120px; margin-top :32px; margin-left :15px; font-size: 12px;" >
              &nbsp;&nbsp;&nbsp;<br />
              <br />
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 会员登录<br />
              <br />
              &nbsp;&nbsp;&nbsp;用户名:<asp:TextBox ID="name" runat="server" 
                  BorderWidth="1px" ForeColor="Black" Height="16px" Width="61px" 
                  BorderColor="#7CAAC6" Font-Size="12px" ontextchanged="Page_Load"></asp:TextBox>
              &nbsp;&nbsp;&nbsp;
              <br />
              &nbsp;&nbsp;&nbsp; 密码:&nbsp;&nbsp; 
              <asp:TextBox ID="pasword" runat="server" BorderWidth="1px" ForeColor="Black" 
                  Height="16px" Width="60px" BorderColor="#7CAAC6" Font-Size="12px" 
                  TextMode="Password"></asp:TextBox>
          &nbsp;&nbsp;&nbsp;
              <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/imges/4.jpg" 
                  onclick="ImageButton1_Click" />        
         </div>
             <%}
         else
         { %>欢迎&nbsp;<%= Session["fullname"] %>&nbsp;&nbsp; 登陆<% }%>