Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7159795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:17:27+00:00 2026-05-28T13:17:27+00:00

I get the following exception when i try to execute specific stored procedure :

  • 0

I get the following exception when i try to execute specific stored procedure :

Input string was in incorrect format

my .cs :

 sQuery.Append("EXECUTE procedure get_department(" + dep_code + "," + emp_code + "," + batch_code + ")");
 return DAL_Helper.Return_DataTable(sQuery.ToString());

I debug and make sure all the parameters are intger.

   public DataTable Return_DataTable(string cmdText)
    {
        Open_Connection();
        DataTable dt = new DataTable();
        command.CommandText = cmdText;
        command.CommandType = CommandType.Text;
        command.Connection = connection;
        try
        {
            dt.Load(command.ExecuteReader());
        }
        catch (IfxException ifxEx)// Handle IBM.data.informix : mostly catched
        {
            ErrMapping.WriteLog("\r\n Error Code: " + ifxEx.Errors[0].NativeError.ToString() +
                                "\r\n MEssage: " + ifxEx.Errors[0].Message);
            throw new Exception("ERROR:" + ifxEx.Errors[0].NativeError.ToString() +
                                "\r\n MEssage: " + ifxEx.Errors[0].Message);
        }
        catch (Exception ex)// Handle all other exceptions.
        {
            ErrMapping.WriteLog("\r\n Error Message: " + ex.Message);
            throw new Exception("\r\n Error Message: " + ex.Message);
        }
        finally
        {
            Close_Connection();
        }
        return dt;
    }

EDIT 1 :

public DataTable Return_DataTable(string cmdText, CommandType cmdType, Dictionary<string, string> Param_arr)
        {
            Open_Connection();
            int return_val = -1;
            DataTable dt = new DataTable();
            command.CommandText = cmdText;
            command.CommandType = cmdType;
            if (cmdType == CommandType.StoredProcedure)
            {
                if (Param_arr != null)
                {
                    command.Parameters.Clear();
                    if (Param_arr.Count > 0)
                    {
                        for (IEnumerator<KeyValuePair<string, string>> enumerator = Param_arr.GetEnumerator(); enumerator.MoveNext(); )
                        {
                            param = command.CreateParameter();
                            param.ParameterName = enumerator.Current.Key.ToString();
                            param.Value = enumerator.Current.Value.ToString();
                            command.Parameters.Add(param);
                        }
                    }
                }
            }
            IfxDataReader dr2;
            try
            {
                dr2 = command.ExecuteReader();
                dt.Load(dr2);
            }
            catch (IfxException ifxEx)// Handle IBM.data.informix : mostly catched
            {
                ErrMappingForInformix.WriteLog("\r\n Error Code: " + ifxEx.Errors[0].NativeError.ToString() +
                                    "\r\n MEssage: " + ifxEx.Errors[0].Message);
                throw new Exception("ERROR:" + ifxEx.Errors[0].NativeError.ToString() +
                                    "\r\n MEssage: " + ifxEx.Errors[0].Message);
            }
            catch (Exception ex)// Handle all other exceptions.
            {
                ErrMappingForInformix.WriteLog("\r\n Error Message: " + ex.Message);
                throw new Exception("\r\n Error Message: " + ex.Message);
            }
            finally
            {
                Close_Connection();
            }
            return dt;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:17:28+00:00Added an answer on May 28, 2026 at 1:17 pm

    How about this:

    command.CommandText = "get_department";
    command.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add(new SqlParameter("dep_code", dep_code));
    cmd.Parameters.Add(new SqlParameter("emp_code", emp_code));
    cmd.Parameters.Add(new SqlParameter("batch_code", batch_code));
    

    Take a look at the different examples in this article (and more specifically: Listing 4. Executing a stored procedure with a parameter).

    The following line of code:

    sQuery.Append("EXECUTE procedure get_department(" + dep_code + "," + emp_code + "," + batch_code + ")");
    

    is like a desperate attempt to break everything and vulnerable to SQL injection. Never use string concatenations when building your SQL queries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Q: I get the following exception when i try to execute the following query:
I get the following error: Unhandled Exception: System.IO.IOException: The parameter is incorrect. at System.IO.__Error.WinIOError(Int32
When I execute the following query, I get an exception telling me that 'feedItemQuery'
I get the following exception when I try to find and replace in a
I get the following exception when trying to access any nodes of a parsed
I get the following Exception running my app: java.net.SocketException: Permission denied (maybe missing INTERNET
I seemed to get the following exception when trying to deploy my application: Caused
I get the following error when I run a java program: Exception in thread
For the attached code, I get the following compile time error : exception during
The following WMI query throws an exception at serverProtocolsManagement.Get() when sqlHost is an invalid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.