简体   繁体   中英

.NET Core 1.1 application on Mac and SQL Server connection string

I'm having problems in connecting a .NET Core 1.1 application to a remote SQL Server, but only on my Mac because on Windows everything works well.

Said that it's not my application and I'm only trying to make it working, this is my connection string on appsettings.Development.json:

  "ConnectionStrings": {
    "MesDatabase": "Data Source=x.x.x.x\\BLABLA,49331; Initial Catalog=DBNAME; Uid=sa; Pwd=blablabla"
  }

This is the error I get opening the connection:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 25 - Connection string is not valid)

I can't access the server, any idea? I'm almost sure that it's a stupid error on connection string but I cannot find it.

I also tried to create a .udl file on Windows, editing it with correct connection data and taking the resulting connection string opening it with notepad. Nothing, always "connection string is not valid" on Mac.

As Jeroen Monstert said:

It makes no sense to specify both an instance name and a port number. Either specify the instance name, and then let the SQL Server Browser service resolve the port for you, or specify the port, but then leave out the instance name.

My problem was due to the fact that in the connection string I had both the instance name and the port, in combination with a "probably bug" on .NET Core 1.1 because behaviour was different between Mac and Windows. In my case SQL Server Browser was down on the server so I needed to specify the port, and for this reason I had to remove the instance name from the connection string.

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