Firstly there's a similar question on Stack overflow, and I have tried suggestions from the responses, none of which have worked.
I have SQL Server and IIS running on my development machine and have an issue when sending a request to an API running on IIS.
My machine is a newly built Windows 11 box, and I am running the latest version of... everything!
The connection string is fairly basic:
Server=[machine name]\\[instance name];Database=[DB name];User Id=[user name];Password=[pw];TrustServerCertificate=True;
I can log into SSMS with the credentials for the user in the connection string, so I cant see an issue with these.
SQL Server is set to "SQL Server and Windows authentication mode".
I have made changes in the SQL Server Configuration manager snap in regarding TCP/IP to use the static port (1433).
I have a rule set in my firewall (I saw that suggested) to open 1433 - although I can't see why that would be a thing when IIS and SQL Server are on the same machine.
I have uninstalled and reinstalled a couple of times, yet get the same response in Postman.
{
"title": "Error",
"status": 400,
"detail": "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)"
}
The instance name is correct, and SQL server is, as far as I know, configured to allow remote connections, as the box is checked in its properties.
My IIS websites directory setup is a little unorthodox, in that I just created a folder on my D: drive called websites, however I haven't experienced an issue accessing my UI website there, I don't think this is an issue.
I'm a little lost to be honest, although I previously used IIS locally a lot, it's been a few years - I have never had issues connecting to a local database previously.
Server=[machine name]\[instance name]means you need SQL Browser running, is it running? Instead of specifying machine name, just use.\InstanceNameIn the Configuration Manager, is Shared Memory switched on as a protocol?Fairly basicmeans nothing and[machine name]\[instance name];may hide an attempt to connect to the wrong server instance. If you use SQL Server Express,Server=localhost\SQLEXPRESSor.\...etc should work. If you don't use Express and haven't installed SQL Server in a named instance, justServer=.orServer=(local)orServer=localhostwould work. You only need to specify an instance name in the very rare case where SQL Server was installed on a non-default instancelocalhostas address without the fancy instance stuff. Does that work?