这样一段代码写在网站的global.asax.cs文件里protected void Session_Start(Object sender, EventArgs e)
{
SqlConnection myConn=new SqlConnection("server=485C2381458E462;uid=sa;pwd=;database=teacher-student;");
string str1="select Grade,Term,CourseID,CourseName,LearnHours from Teaching_plan";
SqlCommand SqlSele=new SqlCommand(str1,myConn);
myConn.Open();
SqlDataAdapter Adapter=new SqlDataAdapter();
Adapter.SelectCommand=SqlSele;
DataSet myDs=new DataSet();
Adapter.Fill(myDs,"Teaching_plan");
myConn.Close();
Application["TeachingTask"]=myDs;
}运行程序后出现:
Server Error in '/' Application.
--------------------------------------------------------------------------------SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +474
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
WebApplication1.Global.Session_Start(Object sender, EventArgs e) in C:\Inetpub\wwwroot\WebApplication1\Global.asax.cs:39
System.Web.SessionState.SessionStateModule.CompleteAcquireState() +525
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +698
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +66
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +173
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573 请问怎么回事啊?????在线等,可否QQ谈????
{
SqlConnection myConn=new SqlConnection("server=485C2381458E462;uid=sa;pwd=;database=teacher-student;");
string str1="select Grade,Term,CourseID,CourseName,LearnHours from Teaching_plan";
SqlCommand SqlSele=new SqlCommand(str1,myConn);
myConn.Open();
SqlDataAdapter Adapter=new SqlDataAdapter();
Adapter.SelectCommand=SqlSele;
DataSet myDs=new DataSet();
Adapter.Fill(myDs,"Teaching_plan");
myConn.Close();
Application["TeachingTask"]=myDs;
}运行程序后出现:
Server Error in '/' Application.
--------------------------------------------------------------------------------SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +474
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
WebApplication1.Global.Session_Start(Object sender, EventArgs e) in C:\Inetpub\wwwroot\WebApplication1\Global.asax.cs:39
System.Web.SessionState.SessionStateModule.CompleteAcquireState() +525
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +698
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +66
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +173
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573 请问怎么回事啊?????在线等,可否QQ谈????
解决方案 »
- |zyciis| cookies安全问题:是不是没有设置cookies存活期,就不会有安全问题,谢谢
- 如何才叫熟悉???
- 后缀名是ASCX的文件是怎么运行的
- 关于 edit and contiue(sos)
- 难,真的很难,如果有能解决的大虾,给出100做为酬谢!!!!
- 如何自定义服务控件中将js和css输出
- 请朋友们帮忙看看这个网站
- 请各位大侠帮帮忙!Repeater的问题!!!!!!!!!
- 有关在Global.asax中连接数据库,谢谢
- .NET下开发的winform应用程序,能在win98下运行吗?
- 在gridview中我有个categoryID(外键)字段想从category表中绑定categoryName
- gridview模板列的按钮点击后能否不刷新页面?
连接字符串问题或者是Sql server没有启动.
修改这个试试,
参考
http://www.connectionstrings.com/?carrier=sqlserver并确认在server *485C2381458E462*上的sql server服务开启的.
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=485C2381458E462;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>