- Home /
Connection Error with MS SQL 2014 and Unity3D
Dear Moderators, I made a game with a Login screen. to log in, you need to write the username and password which are stored in the database. one week ago it was working fine and didn't had any error, but i got all of a sudden an error and i dont know how i got this error because it did work 1 week ago. this is my error: ///////////////////////////////////////////////
SocketException: Er is een adres gebruikt dat niet compatibel is met het aangevraagde protocol.
System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) System.Net.Sockets.Socket+Worker.Connect () Rethrow as TdsInternalException: Server does not exist or connection refused. Mono.Data.Tds.Protocol.TdsComm..ctor (System.String dataSource, Int32 port, Int32 packetSize, Int32 timeout, TdsVersion tdsVersion) Mono.Data.Tds.Protocol.Tds..ctor (System.String dataSource, Int32 port, Int32 packetSize, Int32 timeout, TdsVersion tdsVersion) Mono.Data.Tds.Protocol.Tds70..ctor (System.String server, Int32 port, Int32 packetSize, Int32 timeout, TdsVersion version) Mono.Data.Tds.Protocol.Tds80..ctor (System.String server, Int32 port, Int32 packetSize, Int32 timeout) Mono.Data.Tds.Protocol.TdsConnectionPoolManager.CreateConnection (Mono.Data.Tds.Protocol.TdsConnectionInfo info) Mono.Data.Tds.Protocol.TdsConnectionPool.GetConnection () System.Data.SqlClient.SqlConnection.Open () Rethrow as SqlException: Server does not exist or connection refused. System.Data.SqlClient.SqlConnection.Open () (wrapper remoting-invoke-with-check) System.Data.SqlClient.SqlConnection:Open () Login.LoginButton () (at Assets/Script/Login.cs:49) UnityEngine.Events.InvokableCall.Invoke (System.Object[] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:153) UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:630) UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:765) UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:53) UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:35) UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:44) UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:52) UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:269) UnityEngine.EventSystems.EventSystem:Update()
/////////////////////////////////////
when i click on the error it shows my Connection.Open(). ill post the script/code below:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
using System.Text.RegularExpressions;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
public class Login : MonoBehaviour {
public GameObject username;
public GameObject password;
public Text errormessage;
public static string UN;
private string PW;
private string Form;
void Start () {
errormessage.text = "";
username.GetComponent<InputField>().Select();
}
void Update () {
UN = username.GetComponent<InputField>().text;
PW = password.GetComponent<InputField>().text;
if (UN != "")
{
if (Input.GetKeyDown(KeyCode.Tab))
{
if (username.GetComponent<InputField>().isFocused)
{
password.GetComponent<InputField>().Select();
}
}
if (username.GetComponent<InputField>().text != "" &&
password.GetComponent<InputField>().text != "" &&
Input.GetKeyDown(KeyCode.Return))
{
LoginButton();
}
}
}
public void LoginButton()
{
SqlConnection con = new SqlConnection(@"Data Source=(local);Initial Catalog='Roll A Ball';Integrated Security=True");
bool login = false;
con.Open();
string sql = "SELECT * FROM Login WHERE Username='" + UN + "' and Password='" + PW + "'";
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
login = true;
}
dr.Close();
con.Close();
if (login == true)
{
Application.LoadLevel(1);
}
else
{
errormessage.text = "Failed To Log In";
}
}
}
i have searched a lot on Google, Unity and stackoverflow but with no success. i hope you guys can help me with this error
Hey Everybody and $$anonymous$$oderators. i am not sure but i think i found the problem but not a solution. as far i see, the errormessage says that maybe the port is wrong. i did check the ports of the $$anonymous$$SSQL server and TCP/IP are enabled and are all at port 1433. as far i know is this correct but it still gives the same error. this was a bit more information. i hope you guys can still help me with finding a solution