I am currently trying to connect to a database made in MS SQL Server and My program works on my system but when i want to access it through other computers in the same network but i can not. How could i edit my connection string? Which settings i should do on SQL server? Should i install SQL server management studio on other computers in the network? Below is my code and an explanation of what is going wrong. connection string and Error enter image description here
Asked
Active
Viewed 329 times
0
-
2If you paste the error message into the search box, you'll find hundreds of answers to that. I think the most useful could be this http://stackoverflow.com/questions/18060667/why-am-i-getting-cannot-connect-to-server-a-network-related-or-instance-speci – René Vogt Mar 30 '16 at 11:08
-
i tried many solutions that they said...but they did not work.i am fraustrated – Sedighe Rahimi Mar 30 '16 at 13:21
2 Answers
0
- Press Win+R to open Run command
- Type services.msc and click OK
- Check that SQL Server(Instance Name) must be in Running state.
Another thing you can try is
- Open SQL Server Management Studio.
- Right click on Server in Object Explorer and select Properties
- Go to Connections tab and Allow remote connections to this server checkbox must be checked

M.S.
- 4,283
- 1
- 19
- 42
0
Probably you have not configured Firewall on your main desktop(consider as server), So Configure the Windows Firewall to Allow SQL Server Access. open port 1433
in windows firewall.
Also do the following steps in Server system:
- Make sure tcp/ip is enabled in Sql Server Network Configuration
- Set port :1433
- Restart sql server
- Configure the Windows Firewall to Allow SQL Server Access like mentioned
EDIT: See how to Configure the Windows Firewall to Allow SQL Server Access.

Salah Akbari
- 39,330
- 10
- 79
- 109
-
-
@SedigheRahimi...So probably your problem is with your connection string. Can you show your connection string also? – Salah Akbari Mar 30 '16 at 11:11
-
-
@SedigheRahimi...Well, what is the `ServerName` and `DBName`'s values? – Salah Akbari Mar 30 '16 at 11:21
-
they are two variables: public string ServerName = @"tcp:shiva-pc,49172"; public string DBName = "mydb"; – Sedighe Rahimi Mar 30 '16 at 11:25
-
I open the port 49172 on firewall and shiva-pc is computer name – Sedighe Rahimi Mar 30 '16 at 11:28
-
@SedigheRahimi....You need to open the port `1433` in your firewall and also your server name seems to be incorrect change it to something like this: ServerName = `shiva-pc`. – Salah Akbari Mar 30 '16 at 11:31
-
-
i could not set port to 1433,i dont know why...but it makes an error "windows could not start the sql server(mssqlserver2)on local computer.for more information , review the system event log.... – Sedighe Rahimi Mar 30 '16 at 13:19
-
@SedigheRahimi...See my updated answer to see how to Configure the Windows Firewall to Allow SQL Server Access. – Salah Akbari Mar 30 '16 at 14:16