Convert inaccurate characters during translation

I often encounter the following error when trying to authenticate users:

ERROR [HY000] [Informix .NET provider]Inexact character conversion during translation. 

  public static int IsValidPortalUser(string p_u, string p_p) { int ret = 0; using (IfxConnection conn = new IfxConnection(connectionString)) { IfxCommand DBCmd = new IfxCommand(); String p = My_Decryption_2(p_p); try { if (conn.State == ConnectionState.Closed) conn.Open(); DBCmd = new IfxCommand(); DBCmd.Connection = conn; DBCmd.CommandText = "SELECT nvl(emp_num,0) FROM emp_mas_queue WHERE username = ? AND DECRYPT_CHAR(password, 'XXXXXX') = ? "; DBCmd.Parameters.Add("user_name", p_u); DBCmd.Parameters.Add("password", p); using (IfxDataReader dataReader = DBCmd.ExecuteReader()) { if (dataReader.Read()) { if (dataReader[0] != null && !string.IsNullOrEmpty(dataReader[0].ToString())) { ret = int.Parse(dataReader[0].ToString()); } } dataReader.Close(); } } catch (ThreadAbortException e) { } catch (ApplicationException e) { } conn.Close(); return ret; } } 
+6
source share
2 answers

I believe this may be a coding issue.

I found this article (translated via google translate)

link

This is usually caused by the fact that people copy + paste their data from a source with a different encoding. Try converting the string to some kind of code page that you use before processing them.

+2
source

Since this is the only place in stackoverflow where this error is mentioned, I add that I resolved a similar problem by specifying DB_LOCALE and CLIENT_LOCALE at the connection string level, making sure they were identical and consistent with the DB_LOCALE database.

Changing environment variables did not work.

I have to say that it was on Windows 10 with the following client version: clientsdk.4.10.TC6DE.WIN

+1
source

Source: https://habr.com/ru/post/922834/


All Articles