I have two servers: AppServer with IP 192.168.1.2 and DBServer with IP 192.168.1.3
On DBServer I have the database EMSMVC in the DBSERVER\SQLEXPRESS
instance. The database is working.
On the AppServer in web.config
I have:
<add name="DefaultConnection"
connectionString="Data Source=;Initial Catalog=EMSMVC;Integrated Security=True;Server=192.168.1.3;user id=DBSERVER\admin;password=admin"
providerName="System.Data.SqlClient" />
<add name="EMSMVCEntities"
connectionString="metadata=res://*/Models.EMSModel.csdl|res://*/Models.EMSModel.ssdl|res://*/Models.EMSModel.msl;provider=System.Data.SqlClient;provider connection string="data source=DBSERVER\SQLEXPRESS;initial catalog=EMSMVC;integrated security=True;Server=192.168.1.3;user id=admin;password=DBSERVER\admin;multipleactiveresultsets=True;application name=EntityFramework""
providerName="System.Data.EntityClient" />
When I browse the app in the AppServer I get the following error:
[SqlException (0x80131904): Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.]
However, I'm not trying to connect using Anonymous logon.
Your connection string is flawed with several problems:
<add name="DefaultConnection"
connectionString="Data Source=;Initial Catalog=EMSMVC;Integrated Security=True;Server=192.168.1.3;user id=DBSERVER\admin;password=admin"
providerName="System.Data.SqlClient" />
You have both a Data Source
(with no value) and a Server
- you should use one or the other - but not both. Both basically mean the same thing - you neither of them is specifying the \SQLEXPRESS
instance name ....
You're specifying an User Id
(and password) in the connection string - but also Integrated Security=True
, which means use the built-in Windows authorization - again: if you want to use User Id
; then you must NOT also specify Integrated Security
at the same time - this setting will take precedence over the specified User Id
.
So your connection string should really be:
<add name="DefaultConnection"
connectionString="Data Source=DBSERVER\SQLEXPRESS;Initial Catalog=EMSMVC;User id=DBSERVER\admin;password=admin"
providerName="System.Data.SqlClient" />
or using the IP address instead of the machine name:
<add name="DefaultConnection"
connectionString="Data Source=192.168.1.3\SQLEXPRESS;Initial Catalog=EMSMVC;User id=DBSERVER\admin;password=admin"
providerName="System.Data.SqlClient" />
or if you prefer the Server=
instead of the Data Source=
setting:
<add name="DefaultConnection"
connectionString="Server=192.168.1.3\SQLEXPRESS;Initial Catalog=EMSMVC;User id=DBSERVER\admin;password=admin"
providerName="System.Data.SqlClient" />
User contributions licensed under CC BY-SA 3.0