日期:2014-05-18 浏览次数:20717 次
<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(); }