Call QSYS.QCDEXC from C#

Posted on 2009-02-18
Last Modified: 2012-05-06
I was able to run this successfully in the past  -


but now I'm getting the following error:

Error opening connectionERROR [HY000] [IBM][iSeries Access ODBC Driver][DB2 UDB]CPF1338 - Errors occurred on SBMJOB command.

Any ideas what could cause this error message when it worked before?  Is this a type of permissions issue on DB2?  Or a configuration issue?  What port is DB2 going over for its connection?  They closed down a bunch of ports here recently.  I'm using the i5 Series ODBC client driver.  Or - this there something wrong with the command I'm sending?  

thanks for your help!




        using (OdbcCommand myCommand2 = new OdbcCommand(postCommand, myConnection))


                    if (myConnection.State == System.Data.ConnectionState.Closed)





                    int iRows = myCommand2.ExecuteNonQuery();



            catch (Exception ex)


                System.Diagnostics.Debug.WriteLine("Error opening connection" + ex.Message);

                return false;


Open in new window

Question by:coecho
    LVL 34

    Expert Comment

    by:Gary Patterson
    That message means that the command made it to the command server job on the AS/400, but for some reason the command failed.  The easiest thing to do:

    Sign onto the AS/400 in a green-screen session, preferably using the same profile that you use to submit the command.  Manually submit the command.  When the command failes, you can look at the detailed help (cursor on the error message, press F1) for a detailed explanation of the problem.  It could be lots of things:
    • Program J09110Z could be missing, deleted, moved, or renamed,
    • The library list could have changed for the user profile that the SBMJOB is being run under, and the system could be having trouble finding a required object.
    • User profile FORECAST could be deleted, disabled, or authority to a required object (program, jobd) revoked.
    - Gary Patterson
    LVL 34

    Accepted Solution

    As to the rest of your questions:

    Q: Is this a type of permissions issue on DB2?

    A: You need to se the detailed error messages to determine if it is a permissions issue.  The profile that you use to make the connection must have adequate rights to the FORECAST user profile on ther AS/400, and to the CALL command, the SBMJOB command, and the qcmdexec program.  The FORECAST profile needs to have rights to the program (and it's dependent objects unless it uses adopted authority), and the QPGMR job queue.

    Q: Or a configuration issue?  
    A: Probably not.  Looks like the command is making it to the AS/400 and attempting execution.  The command is just failing for some reason.

    Q: What port is DB2 going over for its connection?
    A: Ports are configurable.  Here's a good article:

    Q:  Or - this there something wrong with the command I'm sending?  
    A:  The command appears to be properly formed and syntactically valid.  Since the program name is not qualified with a library name, the program J09110Z needs to be found in a library in the job's library list.  This will be the job description associated with the user profile FORECAST.  

    - Gary Patterson


    Author Comment

    Hi Gary -

    I was able to run the command on the green screen under a different account than I was trying to run the code under.  It turns out, that the JDE User I was using on the ODBC connection string, had the user permissions changed so that it no longer has permissions to run the DB2 CMD.  

    Problem solved.  Thanks for your help.

    LVL 34

    Expert Comment

    by:Gary Patterson
    It sounded like something had changed.  Glad you could track it down.

    - Gary Patterson
    LVL 16

    Expert Comment

    by:theo kouwenhoven
    Hi coecho,

    I'm almost sure that the comma between the command and the command length is not alowed, parameters in a as400 call are seperated by a space, not by a comma.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now