- Home /
SQL connection problem
Hi, created database for my unity project, and I can easy connect to that db through visual studio but in unity with exactly the same code the unity raise an error:
System.Data.SqlClient.SqlException: Server does not exist or connection refused. Mono.Data.Tds.Protocol.TdsInternalException: Server does not exist or connection refused...
when im trying to open connection (connectionstring.open()).
This is my connection string static BaseSQLHelper() { sqlString.InitialCatalog = "NazwaBazy"; sqlString.DataSource = @"localhost"; sqlString.IntegratedSecurity = true; polaczenie = new SqlConnection(sqlString.ConnectionString); }
and im doing it like this
private static bool ExecuteScalar(SqlCommand com) { com.Connection = polaczenie; bool result = false;; try { polaczenie.Open(); object ob = com.ExecuteScalar(); if(ob.ToString() == "1") { Debug.Log(ob.ToString()); result = true; } polaczenie.Close(); } catch (SqlException sqlEx) { Debug.Log(sqlEx.ToString()); } catch (Exception Ex) { Debug.Log(Ex.ToString()); } finally { polaczenie.Close();
}
return result;
}
Why i can connect through visual studio with exactly the same code but i cant do it by unity? what did i miss?
Your answer
Follow this Question
Related Questions
Firebase Connection error 0 Answers
problem in database connection 2 Answers
Sql Server Compact 4.0 error 2 Answers
database creation without .dll file 1 Answer
MasterServer errors 1 Answer