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; } }
source share