哪为大人帮帮我 得到页面上的值后,写一个SQL语句到判断一下,得到一个返回值就可以了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 protected void btlogin_Click(object sender, EventArgs e) { string sconn = ConfigurationSettings.AppSettings["data"]; string sSql = "select AdminPwd from Admin where '" + this.tblogin.Text.ToString() + "' in(select AdminPwd from Admin)"; SqlConnection conn = new SqlConnection(sconn); SqlCommand comm = new SqlCommand(sSql, conn); try { conn.Open(); if (comm.ExecuteScalar().ToString() == null || comm.ExecuteScalar().ToString() == "") { this.lblogin.Text = "密码不正确!"; } else { Session["UserLogin"] = "true"; Session["UserLogin"] = this.tblogin.Text; Response.Redirect("Module.aspx"); } } catch { this.lblogin.Text = "密码不正确!"; } finally { conn.Close(); conn.Dispose(); comm.Dispose(); } }这样就能满足你的要求了 我要了 你段代码 不过提示我ConfigurationSettings以过时, 而且输入了正确的密码也是提示密码错误 哪里地问题呀? 警告 1 “System.Configuration.ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings” 这样的错误 下面的C#代码哪儿错了?我的163和qq邮箱都开通了Smtp服务了 做了个登录框,登录的时候点两下就会出现好多以前登录过的用户名,怎么才能去掉这些历史记录呢 C#WinForm里如何连接网络服务器上Orcale数据库 水晶报表如何在设计阶段就预定页数呢 usercontrol控件??? 如何动态加载OCX控件 Process.Start出错 dataGridView导出到Excel出点问题 在C#中用API怎样取得网卡地址???????? 请问C#里是不是所有的控件样式都可以自定义? 防止一个按钮多次点击如何用线程控制(WinForm) 各位高人,将Excel导入SQL中,怎么有句话老出错?
{
string sconn = ConfigurationSettings.AppSettings["data"];
string sSql = "select AdminPwd from Admin where '" + this.tblogin.Text.ToString() + "' in(select AdminPwd from Admin)";
SqlConnection conn = new SqlConnection(sconn);
SqlCommand comm = new SqlCommand(sSql, conn);
try
{
conn.Open();
if (comm.ExecuteScalar().ToString() == null || comm.ExecuteScalar().ToString() == "")
{
this.lblogin.Text = "密码不正确!";
}
else
{
Session["UserLogin"] = "true";
Session["UserLogin"] = this.tblogin.Text;
Response.Redirect("Module.aspx");
}
}
catch
{
this.lblogin.Text = "密码不正确!";
}
finally
{
conn.Close();
conn.Dispose();
comm.Dispose();
}
}
这样就能满足你的要求了