0

This application that i am trying to create, whose "instances/copies" will be installed on multiple PCs of the client and are able to access the same database from another PC of the same client that has SQL server running all the time through the same network(i.e: they have the same router and static IP of server etc).

I had two ways to do this:

  1. To make applications use the same database through synchronization.
  2. To have multiple localdbs that then share the changes a database server.

By following 1st way,

I tried setting up the Connection String like:

SqlConnection con = new SqlConnection("Data Source =[serverPcIP,Port];Integrated Security=True;Connect Timeout=30");

SqlConnection con = new SqlConnection("SERVER=[serverPcIP]; Port=[portno];Integrated Security=True;Connect Timeout=30");

In Server - Security Settings: I have allowed "SQL Server and Windows Authentication mode"

enter image description here

In Sql Server Configuration Manager > SQL Server Network Configuration > Protocols for SQLEXPRESS => TCP/IP = Enabled; under IP Addresses -> IP1 -> TCP Port = 1433 (port that i used in my connection-string)

enter image description here

In advanced Firewall Setting:

Have enabled the Incoming & Outgoing rules for port 1433.

The exception that i get:

Additional information: 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: TCP Provider, error: 0 - The wait operation timed out.)

enter image description here

Can someone please tell me what configurations (either in connection-String or in SQL server itself) am i missing?

Shekar Kola
  • 1,287
  • 9
  • 15
  • https://stackoverflow.com/questions/18605533/connecting-to-sql-server-using-windows-authentication – A Farmanbar Nov 10 '19 at 11:53
  • Mr.AF still the same error, What i did: `Data Source=192.168.0.107,1433\\SQLEXPRESS;` – Alex Davidson Nov 10 '19 at 12:02
  • it's possible sql server agent is turn off – A Farmanbar Nov 10 '19 at 12:13
  • 1
    When you get past the connection issue, I have a feeling you will have issues with Integrated Security. Are these desktops members of a Domain? Did you configure database security for logins and users? The account used to install sqlexpress will no trouble but others will by default. – Crowcoder Nov 10 '19 at 12:13

3 Answers3

1

Your connection string lacks the instance name e.g. data source=<hostname or ip>\SQLEXPRESS. If your database listens on the default port 1433 you don't need to pass that with the connection string

If you setup a SQL server, you can choose between the default SQL Server instance or the named instance. For SQL Express the default is to install a named instance with the name SQLEXPRESS. If you don't use the default instance and install a named instance instead, you have to pass it with the connection string.

The default SQL Server instance ist just a named instance with the well known name MSSQLSERVER. So if you installed the database instance as the default instance you can connect with <host>[,port] or <host>\MSSQLSERVER[,port]

Daniel Schmid
  • 647
  • 6
  • 12
1

based on your screenshot, under IP1, the ip address is active but not enabled.

also, ip address that starts with 169.x.x.x normally would mean you have set up this network card to use DHCP, but the network card failed to have ip address from the DHCP server.

do you mind try to use static ip address?

0

Consider following steps:

  1. Since you mention the port number using configuration manager, the service required restart. please restart the service if not done so.
  2. Seems you are able to connect via SSMS, once service restarted verify SQL Error log via SSMS -> Managemnt -> SQL Server Logs, you must find a message as follows:
Server is listening on [ 'any' <ipv4> 1433].

Further details, follow these steps. Also, this..

Shekar Kola
  • 1,287
  • 9
  • 15