InfinityGoesAround
InfinityGoesAround

Reputation: 1021

Two strings in Web.config

I have two connectionstrings in my webconfig.

like this:

<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=&quot;data source=\SQLEXPRESS;initial catalog=Dynamicweb-Verploegen-Test_new;user id='VERPLOEGEN\Niels';password='';multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="NAV2DWservice.Properties.Settings.NAVconnectionString" connectionString="Data Source=\SQLEXPRESS;Integrated Security=SSPI;Initial catalog=Verploegen-Test;"/>
 </connectionStrings>

So the above connectionstring works, but the one below doesnt work.

And yes, the datbase name is correct.

Thank you

This is the error:

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()

Yes, I have a login. see imageenter image description here

If I declare it like this:

     <add name="DataAccess_DynamicWebEntities" connectionString="Data Source=DESKTOP-UON3ACI\SQLEXPRESS;initial catalog=Dynamicweb-Verploegen-Test_new;Integrated Security=SSPI;multipleactiveresultsets=True;application name=EntityFramework&quot;" 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)

Was doing the trick:

Upvotes: 0

Views: 151

Answers (3)

Clint B
Clint B

Reputation: 4710

The first connection string uses a SQL server account to login and the second connection string uses a Windows account. Even if the usernames and passwords are the same, they are different accounts to SQL Server and both need to be given permission. Also, to use both SQL Server accounts and Windows accounts, SQL Server must have been setup to use Mixed Authentication Mode.

Upvotes: 0

Rion Williams
Rion Williams

Reputation: 76597

Are you sure that your credentials are correct? As your error message explicitly states that logging into the database failed :

Login failed for user 'VERPLOEGEN\Niels'

It's important to consider that this login information should actually be credentials to log into your SQL Server instance (e.g. sa would be an example of one of these), which can be created similar as seen below :

enter image description here

Otherwise, if you want to use the current user or a domain-level user then try adding the following to your connection string :

Integrated Security=SSPI;

or :

Integrated Security=true;

You may want to try accessing your local SQL instance and attempt to log in within the credentials that you are using to ensure they are correct.

Upvotes: 1

mkerchenski
mkerchenski

Reputation: 1

It looks like a permission issue. The user 'VERPLOEGEN\Niels' cannot access the database.

Upvotes: 0

Related Questions