Deploy Winforms application connected to SQL Server at centralized system

0

I have installed SQL Sever Express on my system and built an app (Winforms) in visual studio by creating a database in my SQL Server.

Now my application is complete, I have to install my app on my client (4-5 pc) all or on the same LAN and after installation when the user is trying to connect to my database located in my system he is getting below error:

System.Data.SqlClient.SqlException (0x80131904): 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)

By searching online, I checked the following points:

  1. I have enabled Remote connection in my SSMS
  2. I have enabled TCP/IP in sql server configuration manager
  3. I have created rule in firewall to allow port 1433
  4. I then restarted SQL Server configuration manager
  5. But when i opened TCP/IP window of Protocols of SQLEXPRESS in my SQL Server configuration manager, at the bottom TCP dynamic port was 12345 (filled with other number) and my TCP port was empty.
  6. I again changed the TCP port to 1433 and cleared the number in TCP dynamic port and restarted SQL server services.
  7. But again when i opened TCP/IP window of Protocols of SQLEXPRESS in my SQL Server configuration manager, at the bottom TCP dynamic port was 12345 (filled with other number) and my TCP port was empty.

After all this when I reinstall the app in my client system I am getting the same error again, so please guide me if I am missing anything. And how to deploy a Winforms application with a database can access in many computers?

This is my current connection string (in the data source I have purposefully changed my hostname to LENOVO for confidential reasons):

<connectionStrings>
   <add name="dbcs" 
        connectionString="Data Source=LENOVO\SQLEXPRESS;Initial Catalog=SQCData;User ID=ABCDE;Password=*****;Integrated Security=false"
        providerName="System.Data.SqlClient" />
</connectionStrings>
sql-server
visual-studio
winforms
deployment
asked on Stack Overflow Dec 23, 2020 by RAVI KUMAR • edited Dec 23, 2020 by marc_s

1 Answer

0

In SQL Server Configuration Manager set TCP port value to 1433 on the IP configuration you and cleanup TCP Dynamic Ports. It should be empty.

The other option is to configure firewall rule not for static port but for SQL Server process. But in this case you will also to create a rule for SQL Server Browser service (port 1434/tcp) and startup the service.

answered on Stack Overflow Dec 23, 2020 by Jacek Wróbel

User contributions licensed under CC BY-SA 3.0