Web.config 中的两个字符串
Two strings in Web.config
我的网络配置中有两个连接字符串。
像这样:
<connectionStrings>
<add name="DataAccess_DynamicWebEntities" connectionString="metadata=res://*/DataAccess_DynamicWeb.csdl|res://*/DataAccess_DynamicWeb.ssdl|res://*/DataAccess_DynamicWeb.msl;provider=System.Data.SqlClient;provider connection string="data source=\SQLEXPRESS;initial catalog=Dynamicweb-Verploegen-Test_new;user id='VERPLOEGEN\Niels';password='';multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="NAV2DWservice.Properties.Settings.NAVconnectionString" connectionString="Data Source=\SQLEXPRESS;Integrated Security=SSPI;Initial catalog=Verploegen-Test;"/>
</connectionStrings>
所以上面的连接字符串有效,但下面的无效。
是的,数据库名称是正确的。
谢谢
这是错误:
System.Data.EntityException: De onderliggende provider is mislukt op Open. ---> System.Data.SqlClient.SqlException: Login failed for user 'VERPLOEGEN\Niels'.
bij System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
bij System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
bij System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
bij System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
bij System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
bij System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
bij System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
bij System.Data.SqlClient.SqlConnection.Open()
是的,我已经登录了。看图
如果我这样声明:
<add name="DataAccess_DynamicWebEntities" connectionString="Data Source=DESKTOP-UON3ACI\SQLEXPRESS;initial catalog=Dynamicweb-Verploegen-Test_new;Integrated Security=SSPI;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="NAV2DWservice.Properties.Settings.NAVconnectionString" connectionString="Data Source=DESKTOP-UON3ACI\SQLEXPRESS;Integrated Security=SSPI;Initial catalog=Verploegen-Test;" />
I get this error:
System.ArgumentException: Het sleutelwoord wordt niet ondersteund: data source.
bij System.Data.EntityClient.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Hashtable synonyms)
bij System.Data.EntityClient.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms)
bij System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
bij System.Data.EntityClient.EntityConnection..ctor(String connectionString)
bij System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
正在做这个把戏:
看起来像是权限问题。用户 'VERPLOEGEN\Niels' 无法访问数据库。
您确定您的凭据正确吗?由于您的错误消息明确指出登录数据库失败:
Login failed for user 'VERPLOEGEN\Niels'
重要的是要考虑到此登录信息实际上应该是登录到您的 SQL 服务器实例的凭据(例如 sa
将是其中之一的示例),可以类似地创建如下所示:
否则,如果您想使用当前用户或域级用户,请尝试将以下内容添加到您的连接字符串中:
Integrated Security=SSPI;
或:
Integrated Security=true;
您可能想尝试访问您的本地 SQL 实例并尝试使用您使用的凭据登录以确保它们是正确的。
第一个连接字符串使用SQL 服务器帐户登录,第二个连接字符串使用Windows 帐户。即使用户名和密码相同,它们对 SQL 服务器来说是不同的帐户,都需要获得权限。此外,要同时使用 SQL 服务器帐户和 Windows 帐户,必须将 SQL 服务器设置为使用混合身份验证模式。
我的网络配置中有两个连接字符串。
像这样:
<connectionStrings>
<add name="DataAccess_DynamicWebEntities" connectionString="metadata=res://*/DataAccess_DynamicWeb.csdl|res://*/DataAccess_DynamicWeb.ssdl|res://*/DataAccess_DynamicWeb.msl;provider=System.Data.SqlClient;provider connection string="data source=\SQLEXPRESS;initial catalog=Dynamicweb-Verploegen-Test_new;user id='VERPLOEGEN\Niels';password='';multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="NAV2DWservice.Properties.Settings.NAVconnectionString" connectionString="Data Source=\SQLEXPRESS;Integrated Security=SSPI;Initial catalog=Verploegen-Test;"/>
</connectionStrings>
所以上面的连接字符串有效,但下面的无效。
是的,数据库名称是正确的。
谢谢
这是错误:
System.Data.EntityException: De onderliggende provider is mislukt op Open. ---> System.Data.SqlClient.SqlException: Login failed for user 'VERPLOEGEN\Niels'.
bij System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
bij System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
bij System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
bij System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
bij System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
bij System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
bij System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
bij System.Data.SqlClient.SqlConnection.Open()
是的,我已经登录了。看图
如果我这样声明:
<add name="DataAccess_DynamicWebEntities" connectionString="Data Source=DESKTOP-UON3ACI\SQLEXPRESS;initial catalog=Dynamicweb-Verploegen-Test_new;Integrated Security=SSPI;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="NAV2DWservice.Properties.Settings.NAVconnectionString" connectionString="Data Source=DESKTOP-UON3ACI\SQLEXPRESS;Integrated Security=SSPI;Initial catalog=Verploegen-Test;" />
I get this error:
System.ArgumentException: Het sleutelwoord wordt niet ondersteund: data source.
bij System.Data.EntityClient.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Hashtable synonyms)
bij System.Data.EntityClient.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms)
bij System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
bij System.Data.EntityClient.EntityConnection..ctor(String connectionString)
bij System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
正在做这个把戏:
看起来像是权限问题。用户 'VERPLOEGEN\Niels' 无法访问数据库。
您确定您的凭据正确吗?由于您的错误消息明确指出登录数据库失败:
Login failed for user 'VERPLOEGEN\Niels'
重要的是要考虑到此登录信息实际上应该是登录到您的 SQL 服务器实例的凭据(例如 sa
将是其中之一的示例),可以类似地创建如下所示:
否则,如果您想使用当前用户或域级用户,请尝试将以下内容添加到您的连接字符串中:
Integrated Security=SSPI;
或:
Integrated Security=true;
您可能想尝试访问您的本地 SQL 实例并尝试使用您使用的凭据登录以确保它们是正确的。
第一个连接字符串使用SQL 服务器帐户登录,第二个连接字符串使用Windows 帐户。即使用户名和密码相同,它们对 SQL 服务器来说是不同的帐户,都需要获得权限。此外,要同时使用 SQL 服务器帐户和 Windows 帐户,必须将 SQL 服务器设置为使用混合身份验证模式。