0

以下是我的 web.config 文件。我目前正在学习如何自己部署网站,因为我没有找到任何资源来学习如何使用连接到 Azure 数据库的 ADO.NET(实体框架/使用 DB 模型)来部署网站。我创建了一个测试页面,它只是从特定表中获取所有记录。在开发中完美运行。我只是上传了 web.config、default.aspx、default.aspx.cs 和 bin 文件夹。我正在使用 go daddy。不幸的是,我收到一条错误消息,告诉我我没有连接到数据库!谁能帮我??!!!

以下是我的错误和堆栈跟踪建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。(提供者:命名管道提供者,错误:40 - 无法打开与 SQL Server 的连接)

说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.Data.SqlClient.SqlException:建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。(提供者:命名管道提供者,错误:40 - 无法打开与 SQL Server 的连接)

源错误:

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 (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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5061898
   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) +239
   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
   System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +52

[EntityException: The underlying provider failed on Open.]
   System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +161
   System.Data.EntityClient.EntityConnection.Open() +98
   System.Data.Objects.ObjectContext.EnsureConnection() +81
   System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +46
   System.Data.Objects.ObjectQuery`1.GetIListSourceListInternal() +13
   System.Data.Objects.ObjectQuery.System.ComponentModel.IListSource.GetList() +10
   System.Web.UI.DataSourceHelper.GetResolvedDataSource(Object dataSource, String dataMember) +54
   System.Web.UI.WebControls.ReadOnlyDataSource.System.Web.UI.IDataSource.GetView(String viewName) +41
   System.Web.UI.WebControls.DataBoundControl.ConnectToDataSourceView() +266
   System.Web.UI.WebControls.DataBoundControl.GetData() +4
   System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +24
   System.Web.UI.WebControls.ListControl.PerformSelect() +34
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
   WebApplication1._default.Page_Load(Object sender, EventArgs e) in C:\...\WebApplication1\default.aspx.cs:15
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

以下是我的 web.config 文件:

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="false" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxx" />
      </assemblies>
    </compilation>
  </system.web>
  <connectionStrings>
    <add name="xxx"  connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=xxx.database.windows.net;Initial Catalog=xxx;Persist Security Info=True;User ID=xxx;Password=xxx;MultipleActiveResultSets=True;Application Name=EntityFramework&amp;quot&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>
4

2 回答 2

2

GoDaddy 可能正在阻止出站连接。

联系他们的支持,或切换到一个体面的主机。

于 2012-04-15T20:50:07.753 回答
1

您是否尝试过配置 SQL Azure 防火墙以允许来自 GoDaddy 服务器的连接?

参考:http: //msdn.microsoft.com/en-us/library/windowsazure/ee621782.aspx

于 2012-04-16T05:49:38.420 回答