I have been battling with this error for two days and I can't find any solutions I have checked that my services are running, Named pipe and TCP/IP are enabled. I am able to login into SQL Server using Windows and SQL Server auth. This is happening when I send a command text to select from a table, the connection state is open but when I do:
var dbCommand = CreateDbCommand(connection, commandText, null, parameters);
return dbCommand.ExecuteReader();
private static IDbCommand CreateDbCommand(IDbConnection connection, string commandText, CommandType? commandType, IEnumerable<Parameter> parameters)
{
var command = connection.CreateCommand();
command.CommandText = commandText;
command.CommandType = commandType ?? CommandType.Text;
foreach (var parameter in parameters)
{
var sqlParameter = command.CreateParameter();
sqlParameter.ParameterName = parameter.Key;
sqlParameter.Value = parameter.Value ?? DBNull.Value;
command.Parameters.Add(sqlParameter);
}
return command;
}
I am getting the error on
return dbCommand.ExecuteReader();
and I have exhausted my patience any help is welcome.
I am using SQL Server 2016 and my website is running under local IIS.
Thanks
PS: this used to work in SQL Server 2012, but is failing since upgrading.
Regards