質問

UPDATE: The code example below works. I changed the connection string. That was the problem. For an alternative (non-ADO) solution, see Mike Wills's link in the comments.

I have a c# class that (if I ever get it working) runs a program written in RPG code on AS/400 - JD Edwards. I know next to nothing about AS/400 and/or JD Edwards.

I've got other classes in my (intranet) web app that connect to JD Edwards, running SQL queries and setting/getting data. All of these are using the IBM.Data.DB2.iSeries dll and are working great.

For this, I wrote a similar class using the aforementioned dll, but it wasn't working. I even read somewhere online that you can't run a program using this dll. I found that a little fishy, but on suggestion from my JD Edwards co-worker, I scrapped the class and re-wrote it using the adodb dll. No data need be returned from this program run. I just want the program to run.

Here is a dummified version of the class:

    private void runJDEProgram() {
        ADODB.Connection cn = new ADODB.Connection();

        cn.ConnectionString = "Provider=ABABAB;Data Source=111.111.111";



        ADODB.Command cmdDetail = new ADODB.Command();
        cn.Open(); //has to be open before setting an active connection.
        cmdDetail.ActiveConnection=cn;


        cmdDetail.CommandType = ADODB.CommandTypeEnum.adCmdText;

        cmdDetail.CommandText = "{{CALL BLAH.BLAH(?,?)}}";


        cmdDetail.Prepared = true;

        cmdDetail.Parameters.Append(cmdDetail.CreateParameter("P1", ADODB.DataTypeEnum.adChar, ADODB.ParameterDirectionEnum.adParamInput, 10, "BLAH123"));
        cmdDetail.Parameters.Append(cmdDetail.CreateParameter("P2", ADODB.DataTypeEnum.adChar, ADODB.ParameterDirectionEnum.adParamInput, 10, "BLAH456"));

        object dummy = Type.Missing; //otherwise, we couldn't get past this.

        cmdDetail.Execute(out dummy, ref dummy, 0);

        cn.Close();
    }

Here's the error I get when it runs:

{"[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"}

Where am I screwing up? Thanks!

EDIT: The connection string works when querying the AS/400 to get/set data. Does it need to be modified for an operation like this, or for use with ADO?

役に立ちましたか?

解決

The connection string has to be different for this, for some reason. I don't use the same connection string for the other classes that just run queries. The above connection string worked fine (with the appropriate values, of course).

It will prompt for password, but the JDE folks here wanted that.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top