This piece of code executes just fine on Visual Studio 2017 and .NET Core v1.1, but the connection times out on Visual Studio for Mac.
using System;
using System.Data.SqlClient;
using System.Data;
namespace test_console_app
{
class Program
{
static void Main(string[] args)
{
using (SqlConnection connection = new SqlConnection(@"Server=xxxx,1433\xxxx;Database=xxxx;User Id=xxxx;Password=xxxx"))
{
using (SqlCommand command = new SqlCommand("Select * from UserAccounts", connection))
{
connection.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(((IDataRecord)reader)[1]);
}
}
}
}
}
}
The exception that is thrown is the following:
"System.Data.SqlClient.SqlException: 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: TCP Provider, error: 25 - Connection string is not valid)"
Anyone know what the issue might be? Thanks.