[英]How to set library list using cwbx.dll and AS400System class from C# to IBM i (iSeries)
I use client access driver to make sql calls to IBM i (an iSeries).我使用客户端访问驱动程序对 IBM i(一个 iSeries)进行 sql 调用。 When using the driver I can specify a library list that will be used when issuing sql commands/functions.使用驱动程序时,我可以指定在发出 sql 命令/函数时将使用的库列表。
I now need to access an iSeries from C# and make calls to CL/RPGLE programs.我现在需要从 C# 访问 iSeries 并调用 CL/RPGLE 程序。 I found that I can create an AS400System object after adding a reference to cwbx.dll.我发现在添加对 cwbx.dll 的引用后,我可以创建一个 AS400System 对象。 However, I am not sure how to set a library list and am having trouble finding documentation on cwbx.dll.但是,我不确定如何设置库列表并且无法找到有关 cwbx.dll 的文档。 Has anyone else been able to use this object to set a library list?有没有其他人能够使用这个对象来设置库列表?
Asked and answered, I know.询问并回答,我知道。 But here's my answer to the question posed.但这是我对提出的问题的回答。
The command CHGLIBL LIBL(<space-separated list of libraries>)
in a cwbx.Command call will force the AS/400 user library list to be the list needed. CHGLIBL LIBL(<space-separated list of libraries>)
的命令CHGLIBL LIBL(<space-separated list of libraries>)
将强制 AS/400 用户库列表成为所需的列表。 It also forces the library list to be in the same order as specified.它还强制库列表与指定的顺序相同。
Also, IMO, the CWBX APIs provide more error details than the SQL interface when calling AS/400 programs (especially CL's).此外,在调用 AS/400 程序(尤其是 CL 的)时,IMO、CWBX API 提供比 SQL 接口更多的错误详细信息。
Per this doc : "CWBX.DLL (The Programmatic interface) allows to do Data Transfer operations programmatically"根据此文档:“CWBX.DLL(编程接口)允许以编程方式进行数据传输操作”
That's not what you're wanting to do.那不是你想要做的。
You probably want to use the DB2 for i .NET provider .您可能希望使用DB2 for i .NET 提供程序。
Documentation for the provider is installed when you select "Programmer's Toolkit" during the IBm iAccess installation.当您在 IBm iAccess 安装期间选择“程序员工具包”时,将安装提供程序的文档。
Did a little more digging, documentation for CWBX.DLL can be found in:进行了更多挖掘,CWBX.DLL 的文档可以在以下位置找到:
C:\\Program Files (x86)\\IBM\\Client Access\\MRI2924\\cwbx.hlp C:\\Program Files (x86)\\IBM\\Client Access\\MRI2924\\cwbx.hlp
It doesn't appear that you can manipulate the library list for a command.您似乎无法操作命令的库列表。 Only a data transfer via the DatabaseUserLibraryList object.仅通过 DatabaseUserLibraryList 对象传输数据。
The recommended way to call RPGLE / CL from .NET would be call them as an SQL stored procedure.从 .NET 调用 RPGLE/CL 的推荐方法是将它们作为 SQL 存储过程调用。 Technically, given the object based nature of the OS, every *PGM (or procedure in a *SRVPGM) object on the box is already a stored procedure and can be called implicitly using the SQL call command.从技术上讲,考虑到操作系统基于对象的特性,盒子上的每个 *PGM(或 *SRVPGM 中的过程)对象都已经是一个存储过程,可以使用 SQL 调用命令隐式调用。 However, it's beneficial and recommended to explicitly define the RPG / CL interface to the DB using the CREATE PROCEDURE
statement with the EXTERNAL NAME
clause as shown below.但是,建议使用带有EXTERNAL NAME
子句的CREATE PROCEDURE
语句显式定义 RPG / CL 接口到数据库,如下所示。
example from this article这篇文章的例子
Assume you have a *PGM named CUSTINFO, with the following program interface (aka *ENTRY PLIST)假设您有一个名为 CUSTINFO 的 *PGM,具有以下程序界面(又名 *ENTRY PLIST)
D CustInfo PI
D CustNo 5P 0
D Name 15A
D City 25A
D State 2A
D Active 1P 0
Where CustNo is input, the rest of the parms are used as output.在输入 CustNo 的情况下,其余参数用作输出。 Then you can explicitly define this program as an SQL stored procedure simply by running the following:然后,您可以通过运行以下命令,将该程序显式定义为 SQL 存储过程:
CREATE PROCEDURE GetCustInfo
(IN CustNo DEC (5,0), OUT Name CHAR (15), OUT City CHAR(25),
OUT St CHAR(2), OUT Act DEC(1,0))
EXTERNAL NAME MYLIB/CUSTINFO
LANGUAGE RPGLE
PARAMETER STYLE GENERAL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.