It turned out that I had to specify the port i.e. add ",1433" after the server name, so the connection string should be like "Server=servername\\instance,1433;".
Report message to a moderator