连接到Godaddy服务器上的asp.net MSSQL数据库时出错

时间:2019-05-27 06:10:39

标签: c# asp.net sql-server shared-hosting

我从Godaddy购买了Windows“最终共享主机”。我已经上传了所有必需的文件,该站点正常工作。当我在myLittleAdmin上创建数据库并从中获取连接字符串时。我将该连接字符串放到了托管在godaddy上的web.config文件中,但是每当我从托管站点向数据库发送查询时,都会出错。该字符串确实可以在localhost上完美运行。

我只是不知道我做错了什么地方。


这是连接字符串:

<connectionStrings>
    <add name="GodaddyString" connectionString="Data Source=IP;Initial Catalog=db108;Integrated Security=False;User ID=USER;Password=PASS"
    providerName="System.Data.SqlClient" />
</connectionStrings>

这是Web.config文件:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, 
please visit
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <remove name="LocalSqlServer" />
<add name="GodaddyString" connectionString="Data 
Source=IP;Initial Catalog=db108;Integrated 
Security=False;User ID=USER;Password=PASSWORD" 
providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
<trust level="Full" />
<compilation targetFramework="4.6.1" defaultLanguage="c#" />
<httpRuntime targetFramework="4.6.1" />
<urlMappings enabled="true">
  <add url="~/home" mappedUrl="~/index.aspx" />
  <add url="~/ourstory" mappedUrl="~/ourstory.aspx" />
  <add url="~/anual_report" mappedUrl="~/anual_report.aspx" />
  <add url="~/education" mappedUrl="~/education.aspx" />
  <add url="~/error" mappedUrl="~/error.aspx" />
  <add url="~/healthcare" mappedUrl="~/healthcare.aspx" />
  <add url="~/livelihood" mappedUrl="~/livelihood.aspx" />
  <add url="~/joinus" mappedUrl="~/joinus.aspx" />
  <add url="~/mobile-library_stem-project" mappedUrl="~/mlstem.aspx" />
  <add url="~/mission-vision-values" mappedUrl="~/mvv.aspx" />
  <add url="~/our_partners" mappedUrl="~/partners.aspx" />
  <add url="~/the_team" mappedUrl="~/theteam.aspx" />
  <add url="~/our_trustees" mappedUrl="~/trustees.aspx" />
  <add url="~/whole_school_transformation" mappedUrl="~/wst.aspx" />
  <add url="~/contact-us" mappedUrl="~/contact.aspx" />
  <add url="~/volunteer_with_us" mappedUrl="~/volunteers.aspx" />
  <add url="~/ayang@news" mappedUrl="~/ayangsnews.aspx" />
  <add url="~/our-advisors" mappedUrl="~/advisors.aspx" />
  <add url="~/editprofile" mappedUrl="~/editprofile.aspx" />
  <add url="~/change-password" mappedUrl="~/chgpassword.aspx" />
  <add url="~/change-email" mappedUrl="~/chgemail.aspx" />
  <add url="~/edit-user" mappedUrl="~/edituser.aspx" />
  <add url="~/delete-user" mappedUrl="~/deluser.aspx" />
  <add url="~/register-user" mappedUrl="~/adduser.aspx" />
  <add url="~/gallery" mappedUrl="~/gallery.aspx" />
  <add url="~/Gallery/hummingbird-school-picture_viewer" mappedUrl="~/Gallery/gallerypart1.aspx" />
  <add url="~/Gallery/whole-school-transformation-picture_viewer" mappedUrl="~/Gallery/gallerypart2.aspx" />
  <add url="~/Gallery/library-program-picture_viewer" mappedUrl="~/Gallery/gallerypart3.aspx" />
  <add url="~/Gallery/video-album_player" mappedUrl="~/Gallery/gallerypartvideo.aspx" />
  <add url="~/ayang_manthan_fellowship" mappedUrl="~/manthanedufellow.aspx" />
  <add url="~/newsletter" mappedUrl="~/newsletter.aspx" />
  <add url="~/newsletterdel" mappedUrl="~/newsletterdel.aspx" />
  <add url="~/userdashboard" mappedUrl="~/userdashboard.aspx" />
  <add url="~/usereditprofile" mappedUrl="~/usereditprofile.aspx" />
  <add url="~/useremailedit" mappedUrl="~/useremailedit.aspx" />
  <add url="~/dashboard" mappedUrl="~/dashboard.aspx" />
  <add url="~/usereditpassword" mappedUrl="~/usereditpassword.aspx" />
  <add url="~/blogedit" mappedUrl="~/userblogedit.aspx" />
</urlMappings>
<customErrors mode="Off" />
  </system.web>
  <system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <remove name="OPTIONSVerbHandler" />
  <remove name="TRACEVerbHandler" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
  </system.webServer>
  <system.net>
<mailSettings>
  <smtp>
    <network host="relay-hosting.secureserver.net" port="25" />
  </smtp>
</mailSettings>
  </system.net>
      <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
  </dependentAssembly>
</assemblyBinding>
  </runtime>
  <system.codedom>
  </system.codedom>
</configuration>

这是我从托管站点发送查询时遇到的错误:

“ /”应用程序中的服务器错误。

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)

描述:在执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。

异常详细信息:System.Data.SqlClient.SqlException:建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:26-指定服务器/实例时出错)

源错误:

在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来标识有关异常的来源和位置的信息。

堆栈跟踪:

[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.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) +907
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +334
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +699
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +89
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +426
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +191
   System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +154
   System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +21
   System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +90
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +443
   System.Data.SqlClient.SqlConnection.Open() +96
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +120
   System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) +160
   System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +108
   Ayang_Final_Website.login.Login_button_Click(Object sender, EventArgs e) in C:\Users\Jaevein\Desktop\website\Ayang Final Website\Ayang Final Website\login.aspx.cs:39
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9782698
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +204
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1639

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

1 个答案:

答案 0 :(得分:0)

当您的应用程序暂时托管在其他服务器和Godaddy数据库服务器上时,通常会发生此错误。