- Home /
Can't connect to the sql server after build
using UnityEngine; using System.Data.SqlClient; using TMPro;
public class SqlConnectionScript : MonoBehaviour { private string cs; public TextMeshProUGUI txtToSql; void Start() { cs = @"Data Source =192.168.1.2,1433;Initial Catalog=AccountDB;User ID=sa;Password=gamedb;"; }
public void ToSql()
{
SqlConnection SqlConn = new SqlConnection(cs);
SqlConn.Open();
SqlCommand cmd = new SqlCommand("INSERT web_epin (Code, Value, Type, Available) VALUES('" + txtToSql.text + "','28000','1','1')", SqlConn);
cmd.ExecuteNonQuery();
SqlConn.Close();
}
}
Error Log: NotSupportedException: Encoding 1252 data could not be found. Make sure you have correct international codeset assembly installed and enabled.
I'm using sql server 2014 express my DB is SQL_Latin1_General_CP1_CI_AS
Answer by Vazgi · Nov 09, 2021 at 12:08 PM
Well the exception says it all.
There is a problem with the text (Encoding) you are sending. Have you tried to send only numbers or just to encode the text in different encodings(maybe try utf-8).
"Encoding 1252 data could not be found. Make sure you have correct international codeset assembly installed and enabled."
maybe you need to change the language of the sql server.
Thank you for providing an answer. Because the database language has been created previously and it is not allowed to change the language to avoid games that have used it, therefore I switch to control php from unity which is directed to sql server
Your answer
![](https://koobas.hobune.stream/wayback/20220613045135im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to achieve web player like compression in standalone? 2 Answers
Unity Ads System doubt 1 Answer
tiny Question about WebGl and unity 0 Answers
No shadows when building with WebGL? 1 Answer
WebGL on file:/// 0 Answers