Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

MS SQL Server Express 2012 SocketException

Discussion in 'Multiplayer' started by JayShades, Aug 16, 2013.

  1. JayShades

    JayShades

    Joined:
    Mar 13, 2011
    Posts:
    125
    Hello everyone,

    So I've been having a connection problem with the MS SQL Server Express 2012, I cannot seem to connect to it from Unity, I keep getting the error message:

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

    Code (csharp):
    1. var connectionString: String =
    2.           "Server=Jay\\MSSQLSERVER;" +
    3.           "Database=bfcrg;" +
    4.           "User ID=Myuserid;" +
    5.           "Password=mypassword;";
    6.  
    7.        var dbcon: IDbConnection;
    8.        
    9.        dbcon = new SqlConnection(connectionString);
    10.        
    11.        dbcon.Open();
    I did do some research I found out that people have been having this same issue with the MS SQL Server Express 2008 Unity getting the same SocketException.
    as one person had suggested, I uninstalled the server which was installed as a Named Instance(SQLExpress) re-installed it as the Default Instance(MSSQLSERVER). But yeah that didn't fix it :(

    I have also checked it with the Firewall turned off so no it's nothing to do with the Firewall.

    However, I can connect to the Server with the SQL Server Management Studio so the server seems to be working fine I suppose.

    So if anyone has any ideas, please let me know!

    Cheers!
    Thanks a lot!
     
    Last edited: Aug 16, 2013
  2. eskimojoe

    eskimojoe

    Joined:
    Jun 4, 2012
    Posts:
    1,440
    1. Did you enable TCP/IP access to MSSQL? It is usually disabled by default.


    2. Did you open the MSSQL TCP/IP port in Windows Firewall? It is usually closed by default.
     
  3. JayShades

    JayShades

    Joined:
    Mar 13, 2011
    Posts:
    125
    Well I turned the Firewall off completely but it still wouldn't work.

    how exactly would I go on about enabling TCP/IP access to MSSQL? Sorry but I'm really new to MSSQL :)

    P.S. I had a typo in the connection string the new error says: NotImplementedException: Mono does not support names pipes or shared memory for connecting to SQL Server. Please enable the TCP/IP protocol.
     
    Last edited: Aug 16, 2013
  4. JayShades

    JayShades

    Joined:
    Mar 13, 2011
    Posts:
    125
    Figured it out, testing now!
     
  5. JayShades

    JayShades

    Joined:
    Mar 13, 2011
    Posts:
    125
    Oh no way! it works! Thank you so much!!
     
  6. blqck

    blqck

    Joined:
    Dec 2, 2012
    Posts:
    23
    how did you make it , i have the same socket error ?