为什么我的程序运行后,点提交不作处理。

[复制链接]
查看11 | 回复0 | 2005-12-19 10:01:00 | 显示全部楼层 |阅读模式
问题:为什么点提交,不作处理:
WebApplication1中有文件如下:
login.htm, login.aspx,
main.aspx,loginfail.htm
SQL数据库,使用windows验证的。
代码如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace WebApplication1
{

public class login : System.Web.UI.Page

{

private void Page_Load(object sender, System.EventArgs e)

{

string userName=Request.Form["userName"].ToString();

string userPwd=Request.Form["userPwd"].ToString();

SqlConnection con=new SqlConnection("server=.;database=login;table=login;uid=;pwd=;&quot

;

con.Open();

SqlCommand cmd=new SqlCommand("select count(*) from login where userName='"+userName+"' and userPwd='"+userPwd+"'",con);

int count=Convert.ToInt32(cmd.ExecuteScalar());

Response.Write(count);

if (count>0)

{

Response.Redirect("main.aspx&quot

;

}

else

{

Response.Redirect("loginfail.htm&quot

;


}

}

#region Web 窗体设计器生成的代码

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。

//

InitializeComponent();

base.OnInit(e);

}



///

/// 设计器支持所需的方法 - 不要使用代码编辑器修改

/// 此方法的内容。

///

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行