2

I moved from SQL Server 2014 to SQL Server Express (free version) and since then I can't connect to database using SqlConnection with IP.

I can connect local with connection string but when I am using an ip address I get error number 10061, I checked whole net about that error and verified all the issues mentioned: remote connection is allowed, I added port in firewall, enabled tcp in server...

In official version of SQL Server it works fine, but when I moved to EXPRESS free version I can't successfully connect remotely any more.

This is the connection string I use:

SqlConnection cn = new SqlConnection(@"user id = ***; password=***;server=192.168.1.102,1433; Trusted_Connection=no; database=myDatabase; connection timeout=30");    

Getting exception error number 10061.

But when I use the local connection string:

SqlConnection cn = new SqlConnection(@"server=ASUS\SQLEXPRESS ;database=myDatabase;user id = ***; password=***;");    

That works fine...

What can the problem be?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
RAZ
  • 55
  • 8
  • Is SQL Server set up to listen on IP and not just named pipes? Is it also listening on all IP addresses and not just localhost? – DavidG Nov 07 '15 at 20:13
  • Possible duplicate of [Enable remote connections for SQL Server Express 2012](http://stackoverflow.com/questions/11278114/enable-remote-connections-for-sql-server-express-2012) – modal_dialog Nov 07 '15 at 20:15
  • Named pipes is disables by default, How can i set server to listen IP? My server is enabled remote connections.. – RAZ Nov 07 '15 at 20:17
  • A named instance like SQLEXPRESS does not listen on port 1433 by default. Use the SQL Server Configuration Manager Utility to either change the port to 1433 or determine the port SQL Server is using and specify that in the connection string instead of 1433. – Dan Guzman Nov 07 '15 at 20:25
  • You could also try a connectionstring like this: "Data Source=" + Ip + "; Initial Catalog=" + Databasename + "; User ID=" + Username + "; Password=" + Password + "; Connection Timeout=3" – Fruchtzwerg Nov 07 '15 at 20:29
  • Thanks alot friends it's working!!! – RAZ Nov 07 '15 at 21:27

2 Answers2

4

You still need to specify the instance name when switching to using the I.P to connect.

SqlConnection cn = new SqlConnection(@"user id = ***; 
                                       password=***;
                                       server=192.168.1.102\SQLEXPRESS; 
                                       Trusted_Connection=no; 
                                       database=myDatabase; connection timeout=30");  
benni_mac_b
  • 8,803
  • 5
  • 39
  • 59
0

I should have set the port and ip in server configuration manager.

RAZ
  • 55
  • 8