简单登录问题????

taylermail 2008-07-11 05:07:20
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;


public partial class admlg2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}

protected void Submit_ServerClick(object sender, EventArgs e)
{
if (this.user1.Value.Trim() != "")
{
if (this.Password1.Value.Trim() != "")
{
string temp1 = null;
string temp2 = null;
temp1 = this.user1.Value.Trim();
temp2 = this.Password1.Value.Trim();
string connectionstring = "Data Source=192.168.0.4;Initial Catalog=newcxgw;Persist Security Info=True;User ID=zhangjian;Password=cxgw";
SqlConnection con = new SqlConnection(connectionstring);
con.Open();
string cmdtext ="select * from admin where username='temp1' and password='temp2'";
SqlCommand cmd = new SqlCommand(cmdtext, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Session["用户id"] = dr["id"].ToString();
Response.Redirect("3.asp");
}
dr.Close();
con.Close();

}
else { this.Response.Write("<script>alert('用户名或密码错误1!')</script>"); }

}
else { this.Response.Write("<script>alert('用户名或密码错误2!')</script>"); };
}

}
...全文
198 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yagebu1983 2008-07-11
  • 打赏
  • 举报
回复
不知问题所在!!!
godpreserve 2008-07-11
  • 打赏
  • 举报
回复
这里问题太多了.
1.if (dr.Read())
{}
else
{this.Response.Write(" <script>alert('用户名或密码错误1!') </script>");
}
2.你的客户端两个控件吧.要加上<runat="server">
wackyboy 2008-07-11
  • 打赏
  • 举报
回复
啥问题?

110,577

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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