Some insight, closed lab environment, Windows Server 2012 (host) with 2 VM's Windows 8.1 (guests) on INTERNAL Virtual Switch. Host is set as default gateway with ip 1, VMs accordingly 2 and 3. All the entities can see each other on the network, that means I can ping, tracert or share files through file sharing, moreover I can even invoke-command from every place to another.
The deal is that I've got a SQL Server Express instance (SQLEXPRESS
) installed on host but I can't connect to it in Powershell from vm's using following piece of code:
$sql_Server = "HOST\SQLEXPRESS"
$sql_User = "User"
$sql_Password = "Password"
$sql_Database = "Database"
$sql_Connection = New-Object System.Data.SqlClient.SqlConnection
$sql_Connection.ConnectionString = "Server=$sql_Server; Uid=$sql_User; Pwd=$sql_Password; Database=$sql_Database"
$sql_Connection.Open()
All I've got is following error:
Exception calling "Open" with "0" argument(s): "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: 26 - Error Locating Server/Instance Specified)"
Following your questions:
- Firewall if off on all of them,
- Tcp port 1433 enabled,
- above piece of code works from host
I know not much about networks so I guessing that I'm missing something in this puzzle