unity 5.3.5f sql 2008 r2 an existing connection was forcibly closed by the remote host

It appears this question has been asked a few times but no answers which have fixed my issues. I’m running unity 5.3.5f, sql server 2008 express r2 (was running sql 2016 but read that the mono dll’s are only compatible up to sql 2008). i have the correct mono dll’s in my assets folder properly referenced and built in my project. I’m running the database locally. I can get into it fine using sql server management studio and visual studio 2015 connects to it fine as well. i’ve completely dropped the firewall. This will be a client/server setup with this db code executing server side. right now i’m just trying to get it to work within the unity ide. I have also verified incoming connections are allowed in sql server management studio and that tcp/ip is enabled in the sql configuration manager.

My code:

public string RetrieveTestData(string query)
{
string sqlConnectionString =
“Server=zzzz\SQLEXPRESS2008;” +
“Database=mydb;” +
“User ID=sa;” +
“Password=********;”;

        Debug.Log(sqlConnectionString);

        SqlConnection con = new SqlConnection(sqlConnectionString);

        try
        {
            con.Open(); // error on connect

            SqlCommand cmd = new SqlCommand(query, con);

            var fubar = cmd.ExecuteScalar();

            con.Close();

            return fubar.ToString();
        }
        catch (Exception ex)
        {
            Debug.Log(ex.StackTrace);
            throw;
        }

    }

    public void TestQuery()
    {
        Debug.Log(RetrieveTestData("select top 1 * from dbo.Weapon"));
    }

My error: SocketException: An existing connection was forcibly closed by the remote host.

Stack trace: at System.Net.Sockets.Socket.ReceiveFrom_nochecks_exc (System.Byte buf, Int32 offset, Int32 size, SocketFlags flags, System.Net.EndPoint& remote_end, Boolean throwOnError, System.Int32& error) [0x00000] in :0
at System.Net.Sockets.Socket.ReceiveFrom_nochecks (System.Byte buf, Int32 offset, Int32 size, SocketFlags flags, System.Net.EndPoint& remote_end) [0x00000] in :0
at System.Net.Sockets.Socket.ReceiveFrom (System.Byte buffer, System.Net.EndPoint& remoteEP) [0x00000] in :0
at System.Net.Sockets.UdpClient.Receive (System.Net.IPEndPoint& remoteEP) [0x00000] in :0
at System.Data.SqlClient.SqlConnection+SqlMonitorSocket.DiscoverTcpPort (Int32 timeoutSeconds) [0x00000] in :0
at System.Data.SqlClient.SqlConnection.DiscoverTcpPortViaSqlMonitor (System.String ServerName, System.String InstanceName) [0x00000] in :0
at System.Data.SqlClient.SqlConnection.ParseDataSource (System.String theDataSource, System.Int32& thePort, System.String& theServerName) [0x00000] in :0
at System.Data.SqlClient.SqlConnection.Open () [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.Data.SqlClient.SqlConnection:Open ()
at Assets.Scripts.Data.DBBase.RetrieveTestData (System.String query) [0x00013] in C:\Development\Unity wistedshadowsgame\TwistedShadows\Assets\Scripts\Data\DBBase.cs:23
UnityEngine.Debug:Log(Object)
Assets.Scripts.Data.DBBase:RetrieveTestData(String) (at Assets/Scripts/Data/DBBase.cs:35)
Assets.Scripts.Data.DBBase:TestQuery() (at Assets/Scripts/Data/DBBase.cs:43)
Assets.Scripts.Data.DBBase:Start() (at Assets/Scripts/Data/DBBase.cs:48)

All help is greatly appreciated as this is the single item holding up all my progress. If I’ve not posted something or I need to post elsewhere please let me know.

thanks in advance!
ryan

I am having the same problem here, I am working with MS SQL Server 13

public static string conne = "Data Source=GUILTYSPARK343\\SQLEXPRESSVWD;Initial Catalog=VWDemo;uid=Rusoski;pwd=asd1234567";
    public static SqlConnection conn;

public static void Connect()
    {
        conn = new SqlConnection(conne);

        try
        {
            using (IDbConnection dbcon = new SqlConnection(conne))
            {
                dbcon.Open();
            }
                Debug.Log(conn.ConnectionString);
            conn.Close();
            conn.Open();
            
            Debug.Log("I was here0");
        }
        catch (Exception e)
        {
          Debug.Log(e);
        }
    }

Dear @TheDeak / @vitaly-Abileveh,

Were you able to get through this Exception? I have been struggling to get though this issue from past couple of days.

I have checked, re-checked and tried all SQL server side configurations. Also, we use MS SQL server on day to day basis. So I am pretty sure I am missing something on Unity Environment settings.

Kindly reply if something has worked for you.

Thanks in Advance.

Regards,
Swapneel Shah