-2

Well, after doing some research i created a database in MSSql server (2014) and can get a connection via sqlconnection with client, by using:

SqlConnection cn = new SqlConnection("user id = myUSER; password=myPASSWORD;server=mySERVER; Trusted_Connection=yes; database=myDatabase; connection timeout=30");

The connecion exist when my client is local and run on the same machine as MSSQL server, but when i'm on a remote pc i can't connect to the MSSQL server using sqlconnection. How can i connect to that server from remote using sqlconnection - c# ?

JB King
  • 11,860
  • 4
  • 38
  • 49
RAZ
  • 55
  • 8
  • 1
    https://www.google.com/search?q=sql%20server%20allow%20remote%20connections%202014 – Sean Lange Nov 02 '15 at 15:24
  • Beleive me i tried whole net, unfortunately i couldn't find any good solution.. – RAZ Nov 02 '15 at 16:26
  • Well then how about an error message or something to give us a little indication what the problem is? – Sean Lange Nov 02 '15 at 16:27
  • Sorry for that, i thought someone get the problem according to conneaction string, anyway this is my exception: error:0-A connection attempt failed because the connected party did not respod after a period of time... – RAZ Nov 02 '15 at 16:42
  • 1
    Did you try looking for that error message? It has been answered thousands of times. https://www.google.com/search?q=connection+attempt+failed+because+the+connected+party+did+not+respond+after+a+period+of+time&ie=utf-8&oe=utf-8 – Sean Lange Nov 02 '15 at 16:52
  • Ofcourse, and non of the answers were good for me. I think i'm doing wrong with the connection string and i asked for help. Posting a question is my last choice, thanks for help anyway, sorry to bother you. – RAZ Nov 02 '15 at 17:13
  • 1
    It isn't that you are bothering me or anybody else. It is that you haven't provided any information other than you can't connect. If you are uncertain of your connection string go to http://www.connectionstrings.com/. Does your instance allow for remote connections? This is not enabled by default. – Sean Lange Nov 02 '15 at 17:14
  • What if the server isn't configured to allow remote connections? You could try to change the connectionstring all you want, but it won't do anything if the server is configured to deny any remote connection. – JB King Nov 03 '15 at 20:16

1 Answers1

2

Most likely, your SQL Server is not configured to allow remote connections, as Sean Lange points out in one of the comments above.

Carry out these steps from the Management Studio:

  • Right-click on the server name, click on 'Properties'. You'll get the 'Server Properties' window.
  • Click on the 'Connections' tab in the left of this window
  • You'll see a section on the right, that says 'Remote server connections'
  • Check the 'Allow remote connections to this server' checkbox.

Allow remote connections to this server

Krishna Gupta
  • 2,025
  • 19
  • 20
  • This is the 1st thing i did, thanks, (still can't access from remote) – RAZ Nov 03 '15 at 22:01
  • @RanAzrad could you try specifying `Trusted_Connection=False` (instead of `yes`) and see if that works? The `yes` setting is relevant for local Windows logins into SQL Server, and may be messing up the remote login (for which you're giving the username-password creds in the connection string). – Krishna Gupta Nov 03 '15 at 22:33