“/webapps”应用程序中的服务器错误。
--------------------------------------------------------------------------------常规网络错误。请检查您的网络文档。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 常规网络错误。请检查您的网络文档。源错误:
行 103: if(conn.State==ConnectionState.Closed)
行 104: {
行 105: conn.Open();
行 106: }
行 107: SqlCommand cmd=new SqlCommand();
源文件: c:\inetpub\mysite\webapps\login.aspx.cs 行: 105 堆栈跟踪:
[SqlException: 常规网络错误。请检查您的网络文档。]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +484
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
webapps.login.Submit1_Click(Object sender, EventArgs e) in c:\inetpub\mysite\webapps\login.aspx.cs:105
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573 高手指教
--------------------------------------------------------------------------------常规网络错误。请检查您的网络文档。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 常规网络错误。请检查您的网络文档。源错误:
行 103: if(conn.State==ConnectionState.Closed)
行 104: {
行 105: conn.Open();
行 106: }
行 107: SqlCommand cmd=new SqlCommand();
源文件: c:\inetpub\mysite\webapps\login.aspx.cs 行: 105 堆栈跟踪:
[SqlException: 常规网络错误。请检查您的网络文档。]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +484
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
webapps.login.Submit1_Click(Object sender, EventArgs e) in c:\inetpub\mysite\webapps\login.aspx.cs:105
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573 高手指教
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
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.Web.Security;namespace webapps
{
/// <summary>
/// login 的摘要说明。
/// </summary>
public class login : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.TextBox stuusername;
protected System.Web.UI.WebControls.TextBox stupassword;
protected System.Web.UI.WebControls.Button Submit1;
protected System.Web.UI.WebControls.LinkButton LinkButton1;
protected System.Web.UI.WebControls.LinkButton LinkButton2;
protected System.Web.UI.WebControls.LinkButton LinkButton3;
protected System.Web.UI.WebControls.LinkButton LinkButton4;
protected System.Web.UI.WebControls.LinkButton LinkButton5;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label10;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Submit1.Click += new System.EventHandler(this.Submit1_Click);
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
private void Submit1_Click(object sender, System.EventArgs e)
{
if(DropDownList1.SelectedItem.Text=="学生")
{
SqlConnection conn=new SqlConnection("Server=localhost;UID=sa;PWD=;Initial Catalog=studentmanagement");
if(conn.State==ConnectionState.Closed)
{
conn.Open();
}
SqlCommand cmd=new SqlCommand();
string sql="";
sql="SELECT COUNT(*) AS numbers_users_found FROM tblstudentinformation WHERE (studentno='"+stuusername.Text+"')" +"AND(studentpassword='"+stupassword.Text+"')";
cmd.CommandType=CommandType.Text;
cmd.CommandText=sql;
cmd.Connection=conn;
SqlDataReader reader=cmd.ExecuteReader();
while(reader.Read())
{
if(reader.GetValue(0).ToString()!="1")
{
Response.Write("<script>alert('Invalid user name and password .please try it again');</script>"); }
else
{
Session["Studentno"]=stuusername.Text;//session对象有问题
//reader.Close();
FormsAuthentication.RedirectFromLoginPage(stuusername.Text,true);
Response.Redirect("selectcouse.aspx");
reader.Close();
}
}
}
else if(DropDownList1.SelectedItem.Text=="管理员")
{
SqlConnection conn=new SqlConnection("Server=localhost;UID=sa;PWD=;Initial Catalog=studentmanagement");
if(conn.State==ConnectionState.Closed)
{
conn.Open();
}
SqlCommand cmd=new SqlCommand();
string sql="";
sql="SELECT COUNT(*) AS numbers_users_found FROM tbladmininformation WHERE (adminno='"+stuusername.Text+"')" +"AND(adminpassword='"+stupassword.Text+"')";
cmd.CommandType=CommandType.Text;
cmd.CommandText=sql;
cmd.Connection=conn;
SqlDataReader reader=cmd.ExecuteReader();
while(reader.Read())
{
if(reader.GetValue(0).ToString()!="1")
{
Response.Write("<script>alert('Invalid user name and password .please try it again');</script>");
}
else
{
Session["Manageno"]=stuusername.Text;
FormsAuthentication.RedirectFromLoginPage(stuusername.Text,true);
Response.Redirect("adminall.aspx");
reader.Close();
}
}
}
else
{
SqlConnection conn=new SqlConnection("Server=localhost;UID=sa;PWD=;Initial Catalog=studentmanagement");
if(conn.State==ConnectionState.Closed)
{
conn.Open();
}
SqlCommand cmd=new SqlCommand();
string sql="";
sql="SELECT COUNT(*) AS numbers_users_found FROM tblteacherinformation WHERE (teacherno='"+stuusername.Text+"')" +"AND(teacherpassword='"+stupassword.Text+"')";
cmd.CommandType=CommandType.Text;
cmd.CommandText=sql;
cmd.Connection=conn;
SqlDataReader reader=cmd.ExecuteReader();
while(reader.Read())
{
if(reader.GetValue(0).ToString()!="1")
{
Response.Write("<script>alert('Invalid user name and password .please try it again');</script>"); }
else
{
Session["Teacherno"]=stuusername.Text;
FormsAuthentication.RedirectFromLoginPage(stuusername.Text,true); Response.Redirect("teacher.aspx");
reader.Close();
}
} }
} private void LinkButton1_Click(object sender, System.EventArgs e)
{
}
}
}