一个关于SQL2000数据库连接的问题

lqxjlz 2008-05-18 06:11:04
这样一段代码写在网站的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谈????
...全文
74 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lqxjlz 2008-05-18
  • 打赏
  • 举报
回复
苦*行*僧你好,我搞不定,可以把程序发给你帮我看看好吗?你QQ多少
如果方便的话请加我260064088,谢谢!急切
hery2002 2008-05-18
  • 打赏
  • 举报
回复
这个也需要修改一下,参考前面给你那个连接!
lqxjlz 2008-05-18
  • 打赏
  • 举报
回复
跟web。config文件里的这段有 没有关系?

<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=485C2381458E462;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
lqxjlz 2008-05-18
  • 打赏
  • 举报
回复
有人回复了?怎么看不见内容
hery2002 2008-05-18
  • 打赏
  • 举报
回复
SqlConnection myConn=new SqlConnection("server=485C2381458E462;uid=sa;pwd=;database=teacher-student;");
修改这个试试,
参考
http://www.connectionstrings.com/?carrier=sqlserver

并确认在server *485C2381458E462*上的sql server服务开启的.
hery2002 2008-05-18
  • 打赏
  • 举报
回复
SQL Server does not exist or access denied.
连接字符串问题或者是Sql server没有启动.

62,072

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧