简体   繁体   中英

Can't connect to SQL Server Express via IP address - c#

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?

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

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

我应该在服务器配置管理器中设置端口和IP。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM