I have a SQL Server Express instance on a computer with IP 192.168.66 on a home network.
I have enabled TCP/IP on port 49170 and added the incoming rule on Windows firewall.
I have an application that I want to install on different computers inside my network. When I am testing my application in Visual Studio, I am not able to connect to my instance on the remote computer.
<connectionStrings>
<add name="EquipamentoDal.Properties.Settings.ExtinguisherMngConnectionString"
connectionString="Data Source=192.168.1.66,49170;Initial Catalog=ExtinguisherMng;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
The server name is DESKTOP-HU51203\EXPRESS
.
What i have done wrong to not be able to connect?
Your connection string does not specify the Named Instance you're connecting to, it only specifies the IP address, which means any clients will connect to the default instance instead of a named instance.
By default SQL Server Express is configured differently to 'standard' versions of SQL Server (Standard, Workgroup, Developer, and Enterprise Editions) as follows:
SQLEXPRESS
instead of being configured as the Default InstanceAttachDb
andLocalDb
- the other SKUs/Editions do not support theAttachDb
andLocalDb
features.In your case, you've already enabled Remote Connections and you're not using
AttachDb
orLocalDb
, so you just need to configure your client to connect to a named instance:You specify the named instance in your connection string using the format
<host>\<instance name>,<port>
in theData Source=
orServer=
parameter, e.g.Data Source=foo\SQLEXPRESS,1433
, or in your particular case:You mentioned that you're doing this on a Home network, which means it's unlikely you're using an Active Directory or Kerberos, and given SQL Server Express does not expose the passwords it uses for its Service Identity (nor can users authenticate as
NT AUTHORITY\NetworkService
over the network it means you cannot useIntegrated Security=True
(orIntegrated Security=SSPI
which is equivalent, butSSPI
is the preferred value), you will need to set an explicit SQL Server Login's username and password in your Connection String.sa
account, if it exists)Integrated Security=True
withUser Id=<userName>;Password=<password>;