The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.
Проверете настройката на вашия SQL Server, позволяваща приемане на TCP/IP връзки. Активирайте TCP/IP и рестартирайте SQL Server. След това тествайте кода си отново.