主题:[讨论]求助这两段代码有什么错误
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;" >
<br />
<br />
会员登录<br />
<br />
用户名:<asp:TextBox ID="name" runat="server"
BorderWidth="1px" ForeColor="Black" Height="16px" Width="61px"
BorderColor="#7CAAC6" Font-Size="12px" ontextchanged="Page_Load"></asp:TextBox>
<br />
密码:
<asp:TextBox ID="pasword" runat="server" BorderWidth="1px" ForeColor="Black"
Height="16px" Width="60px" BorderColor="#7CAAC6" Font-Size="12px"
TextMode="Password"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/imges/4.jpg"
onclick="ImageButton1_Click" />
</div>
<%}
else
{ %>欢迎 <%= Session["fullname"] %> 登陆<% }%>
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;" >
<br />
<br />
会员登录<br />
<br />
用户名:<asp:TextBox ID="name" runat="server"
BorderWidth="1px" ForeColor="Black" Height="16px" Width="61px"
BorderColor="#7CAAC6" Font-Size="12px" ontextchanged="Page_Load"></asp:TextBox>
<br />
密码:
<asp:TextBox ID="pasword" runat="server" BorderWidth="1px" ForeColor="Black"
Height="16px" Width="60px" BorderColor="#7CAAC6" Font-Size="12px"
TextMode="Password"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/imges/4.jpg"
onclick="ImageButton1_Click" />
</div>
<%}
else
{ %>欢迎 <%= Session["fullname"] %> 登陆<% }%>