我从goaddy那里买了一个Windows"终极共享主机"。我已经上传了所有需要的文件,该网站可以工作。当我在myLittleAdmin上创建一个数据库并从中获取连接字符串时。我将该连接字符串放入托管在 godaddy 上的 web.config 文件中,但每当我从托管站点向数据库发送查询时都会出错。该字符串确实在本地主机上完美运行。
我只是不知道我哪里做错了。
这是连接字符串:
<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 - 查找指定的服务器/实例时出错)
源错误:
在执行 当前网络请求。有关原产地和位置的信息 可以使用下面的异常堆栈跟踪来识别异常。
堆栈跟踪:
[SqlException (0x80131904):与网络相关或特定于实例 建立与 SQL Server 的连接时出错。这 找不到服务器或无法访问服务器。验证实例 名称正确,并且 SQL Server 配置为允许远程 连接。(提供程序: SQL 网络接口,错误: 26 - 错误 查找指定的服务器/实例)] System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential 凭据、对象提供程序信息、字符串新密码、安全字符串 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, 数据库连接选项用户选项) +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 旧连接) +699 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal 旧连接) +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 拥有连接, 任务完成源 1 重试, 数据库连接选项 userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& 连接) +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 重试) +90 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource 1 重试) +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) +120System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, 命令行为) +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 网站\阿阳最终网站\登录.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 事件参数) +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
版本信息: Microsoft .NET 框架版本:4.0.30319; ASP.NET 版本:4.7.3394.0
当您的应用程序托管在其他服务器上并且 Godaddy 数据库服务器暂时关闭时,通常会出现此错误。