日期:2014-05-18 浏览次数:20471 次
SqlConnection conn = new SqlConnection("server=.;uid=sa;pwd=sa;database=emp");
string sql = "select count(*) from t_employee where employee_name = '" + txtUser.Text + "' and password = '" + txtPwd.Text + "'";
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
int count = (int)cmd.ExecuteScalar();
if (count > 0)
{
Server.Transfer("Welcome.aspx");
}
else
{
Response.Write("<script>alert('用户名或密码错误')</script>");
}
------解决方案--------------------
(用三层来实现)
1.首先在数据库建表
2.然后拉控件设计登陆界面,VS连接数据库,这个该回吧;
3.建个类库来放表的实体类
4.建类库(数据层)
5.建个业务层
建议你用 sql2005 和VS2010 ...我有个小的项目有简单的登陆,以及增删查改。
要就回我邮箱: changjian512@163.com