2011-09-09 59 views
3

我在这里使用WebMatrix,并有一个数据库,它都工作得很好,直到它随机向我抛出一个关于连接字符串不存在的错误。这种情况经常发生,我认为这是WebMatrix中的一个错误,它只是在某处忘记或丢失了某个设置,因为它与我所做的任何更改都没有关系。随机SQL连接问题。工程,然后不工作,然后工作,然后BAM!永不再工作?

这里的错误,用堆栈跟踪一起:(道歉这么长的误差)

Server Error in '/' Application. 
-------------------------------------------------------------------------------- 

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) 
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: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) 

Source Error: 


Line 1: @{ 
Line 2:  WebSecurity.InitializeDatabaseConnection("SV", "UserProfile", "UserId", "Email", true); 
Line 3:  WebMail.SmtpServer = "mail.sv.com"; 
Line 4:  WebMail.EnableSsl = false; 


Source File: d:\HostingSpaces\svisible\sv.com\wwwroot\_AppStart.cshtml Line: 2 

Stack Trace: 


[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)] 
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5064474 
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234 
    System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) +341 
    System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +129 
    System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +270 
    System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195 
    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232 
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185 
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33 
    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524 
    System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66 
    System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479 
    System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108 
    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126 
    System.Data.SqlClient.SqlConnection.Open() +125 
    WebMatrix.Data.Database.EnsureConnectionOpen() +44 
    WebMatrix.Data.<QueryInternal>d__0.MoveNext() +71 
    System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +4232308 
    WebMatrix.Data.Database.QuerySingle(String commandText, Object[] args) +103 
    WebMatrix.WebData.SimpleMembershipProvider.CheckTableExists(Database db, String tableName) +59 
    WebMatrix.WebData.SimpleMembershipProvider.CreateTablesIfNeeded() +55 
    WebMatrix.WebData.WebSecurity.InitializeMembershipProvider(SimpleMembershipProvider sMembership, DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean createTables) +73 
    WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51 
    WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51 
    ASP._Page__AppStart_cshtml.Execute() in d:\HostingSpaces\svisible\sv.com\wwwroot\_AppStart.cshtml:2 
    System.Web.WebPages.ApplicationStartPage.<ExecuteInternal>b__3() +65 
    System.Web.WebPages.ApplicationStartPage.<GetSafeExecuteStartPageThunk>b__a(Action action) +7 
    System.Web.WebPages.ApplicationStartPage.ExecuteInternal() +78 
    System.Web.WebPages.ApplicationStartPage.ExecuteStartPageInternal(HttpApplication application, Action`1 monitorFile, Func`2 fileExists, Func`2 createInstance, IEnumerable`1 supportedExtensions) +202 
    System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application, Action`1 monitorFile, Func`2 fileExists, Func`2 createInstance, IEnumerable`1 supportedExtensions) +41 

[HttpException (0x80004005): Exception of type 'System.Web.HttpException' was thrown.] 
    System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application, Action`1 monitorFile, Func`2 fileExists, Func`2 createInstance, IEnumerable`1 supportedExtensions) +88 
    System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application) +287 
    System.Web.WebPages.WebPageHttpModule.StartApplication(HttpApplication application, Action`1 executeStartPage, EventHandler applicationStart) +113 
    System.Web.WebPages.WebPageHttpModule.StartApplication(HttpApplication application) +71 
    System.Web.WebPages.WebPageHttpModule.Init(HttpApplication application) +217 
    System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +517 
    System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194 
    System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339 
    System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253 

[HttpException (0x80004005): Exception of type 'System.Web.HttpException' was thrown.] 
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9079228 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97 
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256 




-------------------------------------------------------------------------------- 
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237 

为什么WebMatrix中保持这样对我?有人可以试着帮我解决这个问题吗?我已经无休止地搜索过,并且发现了许多有点相关的页面,但无法使其工作。

谢谢

+0

您是否监视SQL SErver本身的错误?可能问题不在于应用程序层,而是在数据库层 –

+3

这不是webmatrix,只是与数据库服务器有一个flakey连接。这个错误并不是说连接字符串不存在,而是说它不能连接到数据库。 –

+0

嗯有改变?我正在尝试+1您的评论,但没有选择。 – BENDR

回答