My connection string does not work if I deploy my program to another machine

I have a C # application that works locally, but it does not work if I publish my program on another machine. I get a message that the server name was not found.

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in ProductionOrderQuery.exe

Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or is unavailable. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (vendor: SQL Network Interfaces, error: 26 - Troubleshooting the specified server / instance)

Both machines are in the same corporate domain network. could this be due to the way i specify the name of my server? Do I just need to write the server name or do I need a fully qualified domain name?

Connection string

Server=hostname\\SQLEXPRESS;Database=mydb;Trusted_Connection=True;

I am using SS auth with sa account.

Do I need to do anything on SSMS to get this to work?

Edit: So, since the instructions for connecting through the IP address have been followed to check if this is encrypted with DNS. I configured named pipes and static ports and changed the connection string. Firewall is disabled. Unable to connect remotely, everything works fine locally. I managed to get one machine to connect remotely, and this is very puzzling.

New Connection String - Data Source =

<ip>,1433; Network Library = DBMSSOCN;Initial Catalog = footfall; User ID = sa; Password=password;connection timeout=0;

ping- im, , nslookup . . .

2: - , , . , , - Windows, , SA. , .

: , , combobox , .

VS, . , .

, , , .

SA ( perms ), .

, sa ( , ), , .

, , 2 , , SA ,

.

+4
7

, , combobox , .

VS, . , .

, , , .

SA ( perms ), .

0

, SQL Server (MSSQLSERVER) , .

services.msc SQL Server (MSSQLSERVER) , .

+1

SQL Server Management Studio "", . .

enter image description here

0

:

DESKTOP\SQLEXPRESS

, .

Data Source=.\SQLEXPRESS

!

0

...

, , , .

enter image description here

, sql :

enter image description here

, / dbo. , , sa db_owner .

:

= \SQLEXPRESS; = db; security = false; user id = user; password = pwd; Persist Security Info = True;

/ .

, 2 SQLEXPRESS, .

0

. , :

SQL Server

" SQL Server"

" SQL Server" "" "

Right-click on “TCP / IP” (should be enabled). Click Properties

In the "IP addresses" tab, go to the last entry "IP All"

Enter "TCP port" 1433.

Now restart "SQL Server.Name". using "services.msc" (winKey + r)

0
source

I assume this is a firewall issue. Disable any antivirus or firewall installed on the second computer and see if you can connect.

0
source

Source: https://habr.com/ru/post/1694925/


All Articles