Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

SQL connection problem

$
0
0
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?

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>