Click here to Skip to main content
14,486,704 members
Rate this:
Please Sign up or sign in to vote.
See more:
Following is the query


(" SELECT TO_CHAR(NVL(MAX(ID),0)) FROM BRANCH WHERE UPPER(BRANCHNAME) = UPPER(:VAL) AND COMPANY_ID=:Company_ID ");


o_Cls_OracleConnect.OracleCommand_PreInit(sb.ToString());
         o_Cls_OracleConnect.Parameter_Int32("Company_ID", Company_ID);
         o_Cls_OracleConnect.Parameter_String("VAL", val);

         returnCount = Convert.ToInt32(o_Cls_OracleConnect.ExecuteScalar());
         return returnCount;
     }




public string ExecuteScalar()
    {
        try
        {
            obj_temp = MyCmd.ExecuteScalar();
            if (obj_temp == null)
            {
                s_temp = "";
            }
            else
            {
                s_temp = obj_temp.ToString();
            }
            return (s_temp);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            if (!(MyCmd == null))
            {
                MyCmd.Dispose();
            }
            MyCmd = null;
        }
    }



The error occurs for above function it catches exception : Invalid number. Can any 1 help me to resolve this error.
Posted
Updated 19-Mar-20 10:35am
Rate this:
Please Sign up or sign in to vote.

Solution 1

Hey,

You are using to_char in your select list and you try to convert it to an int32 in code. This will not work....

Regards, Perry
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

In C# Oracle ManagedDataAccess driver use this


Connection.Open();            
OracleGlobalization info = Connection.GetSessionInfo();
info.NumericCharacters = ".,";
Connection.SetSessionInfo(info);
ExecuteNonQuery();
Connection.Close();
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100