I have a virtual machine running on my PC running Windows Server 2008 with SQL Server 2012 installed. When I run SQL Server Management Studio on the VM I can connect as such:
Image showing Management Studio credentials
However, when I run the following C# code outside of the Virtual Machine (VMWare Player) I get an error saying that the server could not be found.
SqlConnection myConnection = new SqlConnection(@"Database=MyDB;Server=WIN-A7D3AQAEQ8C\SQLEXPRESS;Integrated Security=True;connect timeout = 7;");
Error:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
I can ping the Virtual Machine and vice versa. The Virtual Machine's firewall is turned off completely. What am I doing wrong?
CodingYoshi's link will provide a bunch of possible culprits by i strongly suspect (based on the fact you can connect on the VM but not from outside the VM) that your SQL instance only has named pipes enabled as a connection method (this is the default). If you use SQL Server Configuration Manager and enable TCPIP connections try again to connect to your instance from another PC using SSMS and hopefully you will be able to.
To set up TCPIP using Configuration Manager see here: http://support.webecs.com/kb/a868/how-do-i-configure-sql-server-express-to-allow-remote-tcp-ip-connections-on-port-1433.aspx