Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2014
    Posts
    23

    Unanswered: db2 api call debugging

    I've never done an api call, but from what I've read, I think I'm doing it right. I run my asp.net web form, watch it go, and no errors ever come up. Page doesn't crash.

    But the db2 programmer says she doesn't find any new entries.

    I have this...
    Code:
                    try
                    {
                        
                        program.Call(parameters);
                    }
                    catch(Exception ex)
                    {
                        if(system.Errors.Count>0)
                        {
                            foreach(cwbx.Error error in system.Errors)
                            {
                                Response.Write("System: " + error.Text + "<br />");
                                System.Diagnostics.Debug.WriteLine(error.Text);
                            }
                        }
     
                        if(program.Errors.Count>0)
                        {
                            foreach(cwbx.Error error in program.Errors)
                            {
                                Response.Write("Program: " + error.Text + "<br />");
                                System.Diagnostics.Debug.WriteLine(error.Text);
                            }
                        }
                    }
    
                        result = stringConverter.FromBytes(parameters["error"].Value);
                        Response.Write("result is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["ERROR"].Value);
                        Response.Write("RESULT is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["$error"].Value);
                        Response.Write("$result is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["$ERROR"].Value);
                        Response.Write("$RESULT is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["&error"].Value);
                        Response.Write("&result is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["&ERROR"].Value);
                        Response.Write("&RESULT is " + result + "<br />");
    But nothing comes from there either. Any ideas?

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    I don't see any DB2 API calls in your code.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Jan 2014
    Posts
    23
    Ah. Sorry.

    Code:
        private void apiCall(){
                string result =string.Empty;
     
                StringConverter stringConverter =new StringConverterClass();
     
                // Define an AS400 system and connect to it
                AS400System system = new AS400System();
                system.Define(ipaddress);
                system.UserID=user;
                system.Password=password;
                system.IPAddress=ipaddress;
                system.Connect(cwbcoServiceEnum.cwbcoServiceRemoteCmd);
     
                // Check the connection
                if(system.IsConnected(cwbcoServiceEnum.cwbcoServiceRemoteCmd)==1)
                {
                    // Create a program object and link to a system                
                    cwbx.Program program =new cwbx.Program();
                    program.LibraryName = library;
                    program.ProgramName = program;
                    program.system=system;
                    ProgramParameters parameters = new ProgramParameters();
                    parameters.Append("error", cwbrcParameterTypeEnum.cwbrcInout, 80);
                    parameters.Append("ERROR", cwbrcParameterTypeEnum.cwbrcInout, 80);
                    parameters.Append("$error", cwbrcParameterTypeEnum.cwbrcInout, 80);
                    parameters.Append("$ERROR", cwbrcParameterTypeEnum.cwbrcInout, 80);
                    parameters.Append("&error", cwbrcParameterTypeEnum.cwbrcInout, 80);
                    parameters.Append("&ERROR", cwbrcParameterTypeEnum.cwbrcInout, 80);
                    parameters.Append("ahpro", cwbrcParameterTypeEnum.cwbrcInout, 11);
                    parameters["ahpro"].Value = stringConverter.ToBytes(inputProNumber.Text.Trim().PadRight(11, ' '));
    
                    try
                    {
                        
                        program.Call(parameters);
                    }
                    catch(Exception ex)
                    {
                        if(system.Errors.Count>0)
                        {
                            foreach(cwbx.Error error in system.Errors)
                            {
                                Response.Write("System: " + error.Text + "<br />");
                                System.Diagnostics.Debug.WriteLine(error.Text);
                            }
                        }
     
                        if(program.Errors.Count>0)
                        {
                            foreach(cwbx.Error error in program.Errors)
                            {
                                Response.Write("Program: " + error.Text + "<br />");
                                System.Diagnostics.Debug.WriteLine(error.Text);
                            }
                        }
                    }
    
                        result = stringConverter.FromBytes(parameters["error"].Value);
                        Response.Write("result is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["ERROR"].Value);
                        Response.Write("RESULT is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["$error"].Value);
                        Response.Write("$result is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["$ERROR"].Value);
                        Response.Write("$RESULT is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["&error"].Value);
                        Response.Write("&result is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["&ERROR"].Value);
                        Response.Write("&RESULT is " + result + "<br />");
    
                }
     
                system.Disconnect(cwbcoServiceEnum.cwbcoServiceAll);
                System.Diagnostics.Debug.WriteLine(result);
                Response.Write("result is " + result);

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    So you call a program that's supposed to add some entries, and it does not. The problem is then in the program, not in the API, in my view.
    ---
    "It does not work" is not a valid problem statement.

  5. #5
    Join Date
    Apr 2012
    Posts
    1,035
    Provided Answers: 18
    when asking for assistance giving partial or incomplete information, your chances of getting help are limited...

    Give your environment details, what versions/fixpacks are installed, what components are installed *where*, give what basic problem determination you've already done. Such as verifying that the connection to the database succeeded, that the credentials used are permitted to perform the actions you are taking, and whatever db2 API you think you are using actually executes at runtime etc...

    Suggestions: learn about CLI TRACE facilities of your db2-client, add diagnostics to your code.

  6. #6
    Join Date
    Jan 2014
    Posts
    23
    I'm using C# in .NET. I'm using cwbx. I have tried to enter in the wrong password and a message box responded appropriately, so I believe that I have connected successfully.

    I finally got an entry in, but only because the programmer entered that all of my null values would turn to zero, which got me past the data decimal error, talking about "A packed or zoned value does not contain valid numeric data. A digit and/or sign is not valid."

    I logged in the byte array in four ways, stringerConverter, ZonedConverter, PackedConverter, and a raw byte array. The stringConverter and the raw byte array logs the same results and works now due to the programmer making the null values into zero.

    This is what the stringConverter and the raw byte array log shows. This is correctly EBCDIC encoding.
    0
    1
    0
    0
    0
    255
    255
    255
    255
    1
    0
    0
    0
    0
    0
    0
    0
    15
    1
    0
    0
    0
    11
    0
    0
    0
    2
    240
    240
    240
    240
    240
    240
    240
    240
    240
    240
    242
    11

    It's those last eleven characters (0000000001) I submit. I was trying to submit a numeric value but got the decimal data error. My programmer has now turned to strings in order to get my input.

    I'd really like to know how to submit numeric input, but importantly, I'd really like to get the error information. My page does sometimes get the yellow screen of death, but I've yet to get the error from the error parameter that she's put in the program.

    When I record that error parameter, all I get is the same byte array but instead of those eleven characters, it's eighty characters of null.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •