Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inexact character conversion during translation

I face the following error frequently ,when i try 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;
            }
        }
like image 342
Anyname Donotcare Avatar asked Aug 14 '12 13:08

Anyname Donotcare


2 Answers

I believe this may be a problem with encoding.

I located this article (translated through google translate)

link

It is typically caused by people copy+pasting their details from a source with differing encoding. Try converting the string to whichever codepage you are using before processing them.

like image 199
SamuelDavis Avatar answered Sep 23 '22 08:09

SamuelDavis


As this is the only place in stackoverflow where this error is mentionned, I will add that I resolved a similar problem by specifying DB_LOCALE et CLIENT_LOCALE at the connection string level, making sure the two were identical and correponding to the Database DB_LOCALE.

Modifying environnment variables was not working.

I must say it was on a Windows 10 system with the following client version: clientsdk.4.10.TC6DE.WIN

like image 21
Stéphane Gerber Avatar answered Sep 21 '22 08:09

Stéphane Gerber