6

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;
            }
        }
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
  • 1
    What kind of system is your informix databse running on ? – user957902 Aug 14 '12 at 14:14
  • Have you seen this link? http://www-01.ibm.com/support/docview.wss?uid=swg1IV03642 The problem I think is that users have chars either in their name or in their password that break then informix driver. Solution can be: limited acceptable chars, or store the username and/or passowrd in a neutral format (for example base64). – rene Aug 25 '12 at 10:07
  • Could u tell me What do u mean by `chars` in their names ?! – Anyname Donotcare Aug 25 '12 at 11:21
  • It's worth noting that having "decryptable" passwords in your database is a *really bad idea* too. – Jon Skeet Aug 25 '12 at 19:45
  • hmmm , thanks , i know and i'm in debate with my team to tell them that , but what about the problem please ?! – Anyname Donotcare Aug 25 '12 at 19:51
  • 1
    Which locale is your .NET client working in (what is the setting for CLIENT_LOCALE)? Which locale is your database working in? The chances are that the two locales are using different character sets, and there isn't a 1:1 conversion between them, and this message is related to that. Is the Informix server on the same machine as your .NET client? Is it running on a Unix box, perchance? – Jonathan Leffler Aug 29 '12 at 06:56
  • `CLIENT_LOCALE=ar_ae.1256` `DB_LOCALE =ar_ae.8859-6` – Anyname Donotcare Aug 29 '12 at 07:15
  • `Is the Informix server on the same machine as your .NET client?` NO – Anyname Donotcare Aug 29 '12 at 08:11
  • i hope this helps http://publib.boulder.ibm.com/infocenter/idshelp/v117/index.jsp?topic=/com.ibm.cpi.doc/ids_cpi_021.htm this really got my attention cause i ve a linux server with a windows client too and sometimes a little stupid problem can cause a big loss of time. – Berker Yüceer Aug 31 '12 at 05:05

2 Answers2

3

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.

Otherside
  • 2,805
  • 22
  • 21
SamuelDavis
  • 3,312
  • 3
  • 17
  • 19
  • I think you mean encoding, not codepage. +1 for leading me in the right direction with copy/paste. I copied text from a web page straight into visual studio and got this error. Here's a link on how to remove the invalid chars: http://stackoverflow.com/questions/20889996/notepad-how-to-remove-all-non-ascii-characters-with-regex/41149225#41149225 – goku_da_master Dec 14 '16 at 18:08
2

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

Stéphane Gerber
  • 1,388
  • 1
  • 17
  • 30
  • Could you write the connection string please? – Anyname Donotcare Jul 20 '16 at 11:22
  • 1
    t's something like that: `new PDO("informix:host=host.domain.com; service=9800; database=common_db; server=ids_server; protocol=onsoctcp; EnableScrollableCursors=1;DB_CLIENT=us_en.819;DB_LOCALE=us_en.819", "testuser", "tespass"); ` – Stéphane Gerber Jul 22 '16 at 06:49