我有2個相同的連接字符串。一個是ASP.NET會員等,另一個是其他的。爲什麼只有其中一個連接字符串在它們實際上相同時才起作用?
我可以登錄到我的應用程序,所以下面的連接字符串顯然起作用。
<add name="ApplicationServices" connectionString="Data Source=SBS;Initial Catalog=CustomerIntranet;Integrated Security=True;"
providerName="System.Data.SqlClient" />
當我嘗試訪問安全網頁(基於角色的訪問),我得到的可怕:
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)
下面是其他連接字符串:
<add name="CustomerIntranetConnectionString" connectionString="Data Source=SBS;Initial Catalog=CustomerIntranet;Integrated Security=True;"
providerName="System.Data.SqlClient" />
- 我通過遠程桌面連接連接到服務器。
- 我通過一個瀏覽器,服務器
- SQL服務器(SQLSERVER 2005)上運行的應用程序配置了遠程訪問反正
- 我可以登錄
- ASP.NET成員和其他數據庫的東西全部位於同一DB
- 將應用程序部署在IIS 6.0
- 應用程序運行在我的機器罰款(IIS 7.0)
如果任何人都可以她d在這個問題上有一些亮點,那將是非常棒的。我玩過連接字符串,但沒有成功。
只是爲了重申一下,我可以登錄,所以我明顯建立了與數據庫的連接。一旦我打到安全頁面,我就會收到錯誤信息。
謝謝。
PS這裏是堆棧
[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) +5009598
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
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +123
System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) +166
System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +115
DataAccess.IntranetTableAdapters.employeeTableAdapter.GetEmployeeByUserID(Nullable`1 id) +377
BusinessClasses.GlobalOperations.getEmployeeByUserID(Guid id) +96
Customer.EmployeeTimesheet.prepareComponents() +327
Customer.EmployeeTimesheet.Page_Load(Object sender, EventArgs e) +179
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
以下是完整的配置文件:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="Data Source=SBS;Initial Catalog=CustomerIntranet;Integrated Security=True;"
providerName="System.Data.SqlClient" />
<add name="IntranetConnectionString" connectionString="Data Source=SBS;Initial Catalog=CustomerIntranet;Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="8192" executionTimeout="360"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="true" defaultProvider="MyRoleProvider">
<providers>
<clear/>
<add name="MyRoleProvider" type="BusinessClasses.MyRoleProvider, BusinessClasses" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
如果您使用相同的初始目錄 - 爲什麼不使用相同的連接一切?試試看看MARS是否有幫助: –
OakNinja
2013-03-02 10:07:38
感謝您的輸入。我不是100%確定,但我認爲ApplicationServices的東西是ASP.NET成員資格所必需的,因此它有自己的標籤。我嘗試了你的建議,但它沒有改變任何東西。 – spryce 2013-03-02 10:17:09