public partial class login : System.Web.UI.Page
{
public static string strCon = "server= .; uid=sa; pwd=sa; database=hager";
protected void Page_Load(object sender, EventArgs e)
{ }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
string sqlsel = "select count(*) from tUser where fCode='" + TextBox1.Text + " and fPassword='" + TextBox2.Text + "''";
SqlConnection con = new SqlConnection(strCon);
con.Open();
SqlCommand com = new SqlCommand(sqlsel, con);
if (Convert.ToInt32(com.ExecuteScalar())> 0)
{
RegisterStartupScript("", "<script>alert('登录成功!')</script>"); }
else
{
RegisterStartupScript("", "<script>alert('登录失败!')</script>");
}
}
}如上所示,简单的登陆问题。但是输入密码会出现用户代码未处理的提示,在数据库执行的话不是〉0就是=0;
但是我调试的时候在密码框输入任何东西都会抱错,求解决。
{
public static string strCon = "server= .; uid=sa; pwd=sa; database=hager";
protected void Page_Load(object sender, EventArgs e)
{ }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
string sqlsel = "select count(*) from tUser where fCode='" + TextBox1.Text + " and fPassword='" + TextBox2.Text + "''";
SqlConnection con = new SqlConnection(strCon);
con.Open();
SqlCommand com = new SqlCommand(sqlsel, con);
if (Convert.ToInt32(com.ExecuteScalar())> 0)
{
RegisterStartupScript("", "<script>alert('登录成功!')</script>"); }
else
{
RegisterStartupScript("", "<script>alert('登录失败!')</script>");
}
}
}如上所示,简单的登陆问题。但是输入密码会出现用户代码未处理的提示,在数据库执行的话不是〉0就是=0;
但是我调试的时候在密码框输入任何东西都会抱错,求解决。
解决方案 »
- ASP.net做完后怎么发到网上?
- asp.net开发移动web TextBox IME
- 求高手帮助^^^^^^^^^^^^^^刷新问题
- .net2.0,如何获取页面执行时间?
- DropDownList绑定DataSet的问题,请高手们指点
- ASP.net 2.0SQL连接问题
- 我想学asp.net应该如何下手啊。
- 如何插入null值?
- 请问如何在ASP.Net中使用Timer组件
- 运行aspx页面出现“'object' is defined in multiple places; using definition from 'C:\winnt\microsoft.net\framework\v1.0.3705\msco
- 帮我看看一段生成验证码的,为什么生成的字符数组改了没效果。
- 路过的大神 有谁用过ext做后台啊 求救啊
sql语句对吗?
=>
string sqlsel = "select count(*) from tUser where fCode='" + TextBox1.Text + "' and fPassword='" + TextBox2.Text + "'";
" and fPassword='" + TextBox2.Text + "''";
=》"' and fPassword='" + TextBox2.Text + "'";