一个登录页问题

flytigermax200 2005-11-02 07:56:08
请帮我看看下面的代码有什么错?

void ValidateBtn_Click(object sender, System.EventArgs e)
{
string pConnectionString="";
pConnectionString="";
SqlConnection MyConn=new SqlConnection(pConnectionString);
string strSel="";
strSel="Select * from person where name='"+t1+"'"+" and password='"+t2+"'";
SqlCommand cmm=new SqlCommand(strSel,MyConn);
SqlDataAdapter pSqlAdt=new SqlDataAdapter(strSel,MyConn);
DataSet pDst=new DataSet();
DataTable dt=new DataTable();
pSqlAdt.Fill(pDst);

dt=pDst.Tables[0];
if(dt.Rows.Count>0)
{

Response.Write("登录成功");
}
else
{
Response.Write("失败");
}



}

前端代码为

<form runat="server">
<table width="774" border="0">
<tr>
<td width="174"><table width="162" border="0">
<tr>
<td><asp:textBox id="t1" runat="server"></asp:textbox></td>

</tr>
<tr>
<td><asp:textBox id="t2" TextMode="PassWord" runat="server"></asp:textbox></td>

</tr>
<tr>
<td><asp:Button id=Button1 text="登录" OnClick="ValidateBtn_Click" runat="server"/></td>
</tr>

<tr>
<td> </td>
</tr>
</table></td>
<td width="225"> </td>
<td width="361"> </td>
</tr>
</table>

</form>


老是登录失败!
...全文
102 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
flytigermax200 2005-11-03
  • 打赏
  • 举报
回复
我使用Response.Write(strSel);
后是出现了
Select * from person where name='System.Web.UI.WebControls.TextBox' and password='System.Web.UI.WebControls.TextBox'
flytigermax200 2005-11-03
  • 打赏
  • 举报
回复
我使用Response.Write(strSel);

结果是什么都没有!
ar7_top 2005-11-03
  • 打赏
  • 举报
回复
前面开玩笑的

不过有一点疑问,你的 Myconn 都没有 Open
执行的时候没有错误么?
ar7_top 2005-11-03
  • 打赏
  • 举报
回复
用户名随便填
然后密码那里填入
123' Select * from person where name<>'
应该就可以成功登陆...........

白夜花寒 2005-11-02
  • 打赏
  • 举报
回复
Response.Write(strSel);看看是什么结果,还有,你写的这个.net程序......

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧