English 中文(简体)
Best way to access data stored in relational files (not DB2) on an AS400, using .NET?
原标题:

We have need to connect to an AS/400 from .NET (C#) and access (read and write) data.

The issue is the data is stored in relational files on the mainframe, not in a DB2 database.

What is the best way to accomplish this? I would love to use an ADO.NET Entity Framework type solution, but I believe the compatible data providers only work with DB2.

最佳回答

There is a DB2 lite offering and I believe it is offered on the Windows and Linux platforms. The iSeries (AS/400) as well as z-Series (mainframe) use the "full version" of DB2 because it is integrated into the operating system. If I were you, I would ask the mainframe guys if they have the .NET ADO.NET driver from IBM and the connection information for you.

IBM has provided a good redbook on the subject of connecting to the AS/400 (i5). Basically you need to make sure you have the licensed product iSeries Access For Windows (5722-XE1) and you need to setup a data provider on the Systemi. The redbook discusses setting the provider up. The resource for 5722-XE1 is found on the IBM website.

If you would like a older example, there is an article on the four hundred guru site.

Hope this helps -- feel free to post if there is additional information you need or if your administrators have questions about the setup. If you need additional info, make sure you post the OS version (like V5R4 or something like that)

问题回答

I am slightly confused by your terminology, but I am going to make some assumptions and respond.

You mentioned that you are accessing "files" from the AS/400 (aka iSeries, aka IBM i). A "file" is a table. A library is a collection, a record is a row and a field is a column. They are the same thing.

iSeries Access comes with a .NET ADO.NET driver. You can use that and then use SQL as one normally would in an MS SQL database. Some of the functions are different but you can use the manual to figure out those quirks.

It s important to understand that the DB2 engine is embedded in the operating system. Therefore any table in any place is part of the DB2 database. It is ABSOLUTELY NOT important how the file is created (e.g. SQL, RPG, CRTPF, JDBC, COBOL, C). Also, it is ABSOLUTELY NOT important if someone calls the object a file. Everything is really a database table that is in the scope of DB2. You can test that yourself by using the system catalog on the iSeries (e.g. SYSTABLES). Notice that you can find your table in that place. Also, notice that you can use any JDBC or ODBC software to access the data on the iSeries.

That having said, there are some subtle differences. First of all, the DB2 for iSeries is a 100% real DB2 application, but is missing some things from his fellows. For example, MERGE is available on Windows and Unix, but not on the iSeries. Check the IBM Information center for this.

On the iSeries you do have some other objects that can store data. Most used are the DATAAREA and the DTAQ. These objects are NOT part of the DB2 database. Something like the FIFO object on unix is not part of the database

At last but not least, you can work with DB2 the iSeries way, or the DB2 way. The iSeries way is available for guys that grew up with the AS400. For example, you use CATALOG/TABLE instead of CATALOG.TABLE. Normally you would use the DB2 way. Every tool with iSeries support that I know off, does also support the DB2 way. Choose that option and everything works like the books.

How we did it on the mainframe: using CICS web services, we have some transactions that serve up data using SOAP. From a programmer standpoint, it s essentially just writing to a TS queue. Then we use an WSDL generation tool provided by IBM to build the WSDL that describes the service accordingly (with methods, input/output parms, etc). Then on the .NET side, just add a web reference to the WSDL and you are on your way. One caveat: we had create a class that inherits the web service, and overrides GetWebRequest to set KeepAlive to false. You may need to do this as well.

Going the other way (mainframe acting as client), it s basically the same thing (a temp TS que write), except there are a couple different parameters required (such as the URL to the web server to be invoked, name of the method, etc).

There is probably a better way, but we couldn t figure out any other way. I believe we had to take the more difficult route because our OS is not MVS, but rather VSE, which is a cheaper version and does not have very many nice features as MVS. The initial code samples we referenced were written by Richard Smrcina.





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签