问题描述
怎么解决啊???头疼...ServerErrorin'/OSWebSites'Application.Anerrorhasoccurredwhileestablishingaconnectiontotheserver.WhenconnectingtoSQLServer2005,thisfailuremaybecausedbythefactthatunderthedefaultsettingsSQLServerdoesnotallowremoteconnections.(provider:SQLNetworkInterfaces,error:26-ErrorLocatingServer/InstanceSpecified)Description:Anunhandledexceptionoccurredduringtheexecutionofthecurrentwebrequest.Pleasereviewthestacktraceformoreinformationabouttheerrorandwhereitoriginatedinthecode.ExceptionDetails:System.Data.SqlClient.SqlException:Anerrorhasoccurredwhileestablishingaconnectiontotheserver.WhenconnectingtoSQLServer2005,thisfailuremaybecausedbythefactthatunderthedefaultsettingsSQLServerdoesnotallowremoteconnections.(provider:SQLNetworkInterfaces,error:26-ErrorLocatingServer/InstanceSpecified)SourceError:Line11:command.CommandType=CommandType.StoredProcedureLine12:'OpentheconnectionLine13:connection.Open()Line14:'ReturnaSqlDataReadertothecallingfunctionLine15:Returncommand.ExecuteReader(CommandBehavior.CloseConnection)SourceFile:C:DocumentsandSettingsMaoMaoMyDocumentsVisualStudio2008OSWebSitesApp_CodeCatalog.vbLine:13StackTrace:[SqlException(0x80131904):Anerrorhasoccurredwhileestablishingaconnectiontotheserver.WhenconnectingtoSQLServer2005,thisfailuremaybecausedbythefactthatunderthedefaultsettingsSQLServerdoesnotallowremoteconnections.(provider:SQLNetworkInterfaces,error:26-ErrorLocatingServer/InstanceSpecified)]System.Data.SqlClient.SqlInternalConnection.OnError(SqlExceptionexception,BooleanbreakConnection)+800131System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObjectstateObj)+186System.Data.SqlClient.TdsParser.Connect(ServerInfoserverInfo,SqlInternalConnectionTdsconnHandler,BooleanignoreSniOpenTimeout,Int64timerExpire,Booleanencrypt,BooleantrustServerCert,BooleanintegratedSecurity,SqlConnectionowningObject)+737554System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfoserverInfo,StringnewPassword,BooleanignoreSniOpenTimeout,Int64timerExpire,SqlConnectionowningObject)+114System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(Stringhost,StringnewPassword,BooleanredirectedUserInstance,SqlConnectionowningObject,SqlConnectionStringconnectionOptions,Int64timerStart)+421System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnectionowningObject,SqlConnectionStringconnectionOptions,StringnewPassword,BooleanredirectedUserInstance)+181System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentityidentity,SqlConnectionStringconnectionOptions,ObjectproviderInfo,StringnewPassword,SqlConnectionowningObject,BooleanredirectedUserInstance)+173System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptionsoptions,ObjectpoolGroupProviderInfo,DbConnectionPoolpool,DbConnectionowningConnection)+357System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionowningConnection,DbConnectionPoolpool,DbConnectionOptionsoptions)+30System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionowningObject)+424System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionowningObject)+66System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnectionowningObject)+494System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnectionowningConnection)+82System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnectionouterConnection,DbConnectionFactoryconnectionFactory)+105System.Data.SqlClient.SqlConnection.Open()+111Catalog.GetDepartments()inC:DocumentsandSettingsMaoMaoMyDocumentsVisualStudio2008OSWebSitesApp_CodeCatalog.vb:13UserControls_WebUserControl.Page_Load(Objectsender,EventArgse)inC:DocumentsandSettingsMaoMaoMyDocumentsVisualStudio2008OSWebSitesUserControlsDepartmentsList.ascx.vb:20System.Web.UI.Control.OnLoad(EventArgse)+99System.Web.UI.Control.LoadRecursive()+47System.Web.UI.Control.LoadRecursive()+131System.Web.UI.Control.LoadRecursive()+131System.Web.UI.Page.ProcessRequestMain(BooleanincludeStagesBeforeAsyncPoint,BooleanincludeStagesAfterAsyncPoint)+1436VersionInformation:Microsoft.NETFrameworkVersion:2.0.50727.1433;ASP.NETVersion:2.0.50727.1433
解决方案
解决方案二:
你连接的是远程数据库码?
解决方案三:
不是,本地的.
解决方案四:
不是,本地的.
解决方案五:
把相关代码贴上来看看吧
解决方案六:
ImportsMicrosoft.VisualBasicImportsSystem.Data.SqlClientImportsSystem.DataPublicClassCatalogPublicSharedFunctionGetDepartments()AsSqlDataReaderDimconnectionAsNewSqlConnection(connectionString)DimcommandAsNewSqlCommand("GetDepartments",connection)command.CommandType=CommandType.StoredProcedureconnection.Open()Returncommand.ExecuteReader(CommandBehavior.CloseConnection)EndFunctionPrivateSharedReadOnlyPropertyconnectionString()AsStringGetReturnConfigurationSettings.AppSettings("ConnectionString")EndGetEndPropertyEndClass
解决方案七:
GetDepartments这个函数是如何调用的?
解决方案八:
Returncommand.ExecuteReader(CommandBehavior.CloseConnection)这样返回datareader是不对的。我在本机上测试会报错。command.ExecuteReader这种command类型不应该是Procedure
解决方案九:
up
解决方案十:
我这边倒不是其他的问题,就是connection.Open()报错,刚才贴的就是报错的信息
解决方案十一:
connectionString那把这个内容贴上来吧。还有即使你在这里报错,但是到下面还会报错的
解决方案十二:
我在web.config里面addkey<appSettings><addkey="ConnectionString"value="Server=(local)NetSDK;IntegratedSecurity=True;InitialCatalog=Shop"/></appSettings>
解决方案十三:
连接字符串里怎么没有workstationid呢?添加上去看看可以看看这里的连接字符串介绍www.connectionstrings.com
解决方案十四:
好的,谢谢您啊,我现在就去看看