I sent an app for production but I'm getting what appears to be a connection error.
And this is the error when I invoke the api URL
Win32Exception: The parameter is incorrect.
Unknown locationSqlException: 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: 25 - Connection string is not valid)
The error itself is pretty self-explanatory but as far as I understand the connection string is OK
Here's the appsettings.json
in C#:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"Hawk": "Data Source=Hawk.db",
"HawkSQLServer": "Server=vgcserver2\\MSSQLSERVER;Database=HawkNew;User Id=sa;Password=password;"
}
}
The database is named HawkNew
and user sa
has the same password from the connection string (SQL Server 2014).
The server's web.config
file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*"
modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\BackEnd.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
Not sure - but MSSQLSERVER
is typically the "internal" name of the default, unnamed instance - which you do not have to specify when connecting to that server instance.
So I'd try these settings in appsettings.json
:
"ConnectionStrings": {
"Hawk": "Data Source=Hawk.db",
"HawkSQLServer": "Server=vgcserver2;Database=HawkNew;User Id=sa;Password=password;"
}
Also, word of caution: it's generally considered a really bad practice to use the sa
account for your development and especially for production use. Use Windows authentication, if possible - or else create a specific user for your application that has the needed permissions - do NOT use the system administrator account for any serious work!