62,074
社区成员
发帖
与我相关
我的任务
分享
<appSettings>
<add key="FCKeditor:BasePath" value="~/fckeditor/"/>
<add key="FCKeditor:UserFilesPath" value="/Files/" />
</appSettings>
<connectionStrings>
<add name="decoraconn" connectionString="server=localhost;uid=sa;pwd=251209;database=decorations" providerName="System.Data.SqlClient"/>
</connectionStrings>
protected void btnLogin_Click(object sender, EventArgs e)
{
string connstring =System.Configuration.ConfigurationManager.ConnectionStrings["decoraconn"].ConnectionString;
SqlConnection con = new SqlConnection("connstring");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandType=CommandType.Text;
cmd.CommandText ="select * from Admin where account="+tbName.Text;
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
if (dr["password"].ToString() == tbPwd.Text)
{
Response.Redirect("index.aspx");
}
else {
lblMessge.Visible = true;
lblMessge.Text = "登陆失败,密码错误!";
}
}
else {
lblMessge.Visible = true;
lblMessge.Text = "登陆失败,用户不存在!";
}
dr.Close();
}