I am trying to connect to an 2008R2 SQLEXPRESS instance that is running on a 2003 server.
I can connect to the database from within my .net core 2.0 project using Server Explorer
I can run programs written in .net framework that connect to the database.
However when I try to connect from within my .net core project I get the following error
System.Data.SqlClient.SqlException (0x80131904):
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
at System.Data.SqlClient.SqlInternalConnectionTds. etc
The problem is not the format of the connection string because it works on a local back up of the database.
The connection string is in appsettings.json similar to
"ConnectionStrings": {
"MyDatabase": "Server=MySERVER\\SQLEXPRESS;Database=mydatabase;Trusted_Connection=False;User=sa;password=mypassword"
SQL Server Browser is started . I can access the data via Management Studio
I am not running SQL Server Agent. When I try and start it I see in the event logger
SQLServerAgent could not be started (reason: This installation of SQL Server
Agent is disabled. The edition of SQL Server that installed this service
does not support SQL Server Agent.).
I have been able to work around by using the port number in the connection string instead of the instance name.
As advised here
And to find the port I can use
USE master
GO
xp_readerrorlog 0, 1, N'Server is listening on'
GO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With