.NET Core Functions

Find below a detailed documentation of LINK2i functions in .NET Core environments using our WCF Service library.
To learn more: About LINK2i in .NET Core environments


All XML streams are described in detail here.
About Link2i
Description

This function retrieves Link2i version level

Parameters
Returns
  • Version() string
    Formatted character string

//Parameters
Link2i db2 = new Link2i();
string result;

//Function call
result = db2.Version();

//Returned results
result = "LINK2i - V1R0M0 - March 15 2021 - www.aumerial.com/knowledge.aspx";
                                
Create connection strings
Description

LINK2i functions require an encrypted connection string containing the IP address of the targeted IBM i partition and IBM i session credentials (username/password). This connection string is generated using GetConnectionString. The IBM i access is limited to the security roles established in the IBM i for the specified account.

Parameters
  • IP string
    IP address or network location of the targeted IBM i partition
  • userName string
    IBM i account username
  • password string
    IBM i account password
Returns
  • GetConnectionString() string
    LINK2i connection string as string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string IP = "192.168.2.19";
string userName = "QSECOFR";
string password = "PW1234";

//Function call
result = db2.GetConnectionString(IP, userName, password);

//Returned results
result = "connection string to use in other functions";
                                
Explore targeted IBM i partition

These functions allow you to explore the targeted IBM i partition to get a quick in-depth overview of what's inside your machine. They can also be used to interact with other LINK2i functions to specify libraries, files, create user-friendly query wizards...

Description

retrieves licence status

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
Returns
  • AboutLink2iLicense() string
    Formatted message to warn about licence validity expressed in remaining days

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";

//Function call
result = db2.AboutLink2iLicense(connString, sessionID);

//Returned results
result = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
                                
Description

Retrieves targeted IBM i serial number, OS and processor group.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
Returns
  • GetSerialNumberIBMi() string
    IBM i information as string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";

//Function call
result = db2.GetSerialNumberIBMi(connString, sessionID, licenseStatus);

//Returned results
result = "V7R4M0 ABC123 - connection OK";
                                
Description

ListDatabases extracts a list of all databases/libraries from the targeted IBM i partition as an XML string.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
Returns
  • ListDatabases() string
    List as XML string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";

//Function call
result = db2.ListDatabases(connString, sessionID, licenseStatus);

//Returned results
result = "<Databases>...</Databases>";
                                
Description

ListTables extracts a list of all tables/files of the specified database/library from the targeted IBM i partition as an XML string.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • base string
    Name of the database/library whose tables/files are to be listed
Returns
  • ListTables() string
    List as XML string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string base = "LIBTEST";

//Function call
result = db2.ListTables(connString, sessionID, licenseStatus, base);

//Returned results
result = "<Tables>...</Tables>";
                                
Description

ListFields extracts a list of all fields of the specified table/file of the specified database/library from the targeted IBM i partition as an XML string.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • base string
    Database/library containing the table/file whose fields are to be listed
  • table string
    Table/file whose fields are to be listed
Returns
  • ListFields() string
    List as XML string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string base = "LIBTEST";
string table = "TABLETEST";

//Function call
result = db2.ListFields(connString, sessionID, licenseStatus, base, table);

//Returned results
result = "<Fields>...</Fields>";
                                
Description

ListPrograms extracts a list of all programs of the specified database/library from the targeted IBM i partition as an XML string.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • base string
    Database/library whose programs are to be listed
Returns
  • ListPrograms() string
    List as XML string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string base = "LIBTEST";

//Function call
result = db2.ListPrograms(connString, sessionID, licenseStatus, base);

//Returned results
result = "<Programs>...</Programs>";
                                
Description

ListSources extracts a list of all source files of the specified database/library from the targeted IBM i partition as an XML string.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • base string
    Database/library whose source files are to be listed
Returns
  • ListSources() string
    List as XML string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string base = "LIBTEST";

//Function call
result = db2.ListSources(connString, sessionID, licenseStatus, base);

//Returned results
result = "<Sources>...</Sources>";
                                
Description

ListMembers extracts a list of all members of the specified source file of the specified database/library from the targeted IBM i partition as an XML string.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • base string
    Database/library whose members are to be listed
  • srcFile string
    Source file whose members are to be listed
Returns
  • ListMembers() string
    List as XML string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string base = "LIBTEST";
string srcFile = "SOURCETEST";

//Function call
result = db2.ListMembers(connString, sessionID, licenseStatus, base, srcFile);

//Returned results
result = "<Members>...</Members>";
                                
Description

GetObjectDetails retrieves details of any IBM i object as an XML string. It can be used to display object details in a 5250 like interface.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • base string
    Database/library containing the IBM i object
  • ibmObject string
    IBM i object Name
  • objType string
    IBM i object type (*PGM, *FILE, *DEVD, etc...)
Returns
  • GetObjectDetails() string
    Data as XML String
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string base = "LIBTEST";
string ibmObject = "OBJTEST";
string objType = "*PGM";

//Function call
result = db2.GetObjectDetails(connString, sessionID, licenseStatus, base, ibmObject, objType);

//Returned results
result = "<ObjDet>...</ObjDet>";
                                
Database

Run SQL queries and retrieves data in standard structures (XML strings) to integrate DB2 for i databases in any environment. Extract and export data in CSV, TXT and XLSX files.

Description

Runs an SQL query on the targeted IBM i.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • sqlQuery string
    SQL query to execute
Returns
  • RunSql() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string sqlQuery = "update libtest.tabletest set name = 'foo' where name = 'bar'";

//Function call
result = db2.RunSql(connString, sessionID, licenseStatus, sqlQuery);

//Returned results
result = "ASP0001 - Operation sucessful";
                                
Description

Runs a sequence of up to 10 SQL queries in a row.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • sqlQuery string
    SQL query to run
  • delimiter string
    Delimiter used between queries in sqlQuery parameter
Returns
  • RunSqlByTen() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string sqlQuery = "update libtest.tabletest set name = 'foo' where name = 'bar';update libtest.tabletest set product = 'link2i' where machine = 'ibm i'";
string delimiter = ";";

//Function call
result = db2.RunSqlByTen(connString, sessionID, licenseStatus, sqlQuery, delimiter);

//Returned results
result = "ASP0001 - Operation sucessful";
                                
Description

Runs an SQL script. The script can either be composed of SQL queries and CL commands. CL commands must be prefixed by 'CX:' or 'CL:'.
When using CX prefix, the script doesn't stop and resumes on error.
When using CL prefix, the script is interrupted on error.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • sqlScript string
    SQL script to execute
  • delimiter string
    Delimiter used between instructions in sqlScript parameter
Returns
  • RunSqlScript() string
    Messages returned at each step of the script as String
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string sqlScript = "CL:CPYF(...);insert into ... ;CX:DLTF(...)";
string delimiter = ";";

//Function call
result = db2.RunSqlScript(connString, sessionID, licenseStatus, sqlScript, delimiter);

//Returned results
result = "ASP0001 - Operation sucessful";
                                
Description

Exports the result of an SQL SELECT query (simple/join) in a CSV file.
The maximum size of a file is 1 million records. Multiple files are created when exporting more than 1 million records.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • sqlQuery string
    SQL SELECT query to execute
  • dirPath string
    Path of the directory to export files into, uses '\' directories delimiter and ens by '\'
  • outputFileName string
    Name of the resulting csv file without suffix
  • delimiter string
    CSV separator
Returns
  • CopyToCSV() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string sqlQuery = "select * from libtest.tabletest";
string dirPath = "c:\csv\";
string outputFileName = "csvfile.csv";
string delimiter = ";";

//Function call
result = db2.CopyToCSV(connString, sessionID, licenseStatus, sqlQuery, dirPath, outputFileName, delimiter);

//Returned results
result = "ASP0001 - Operation sucessful";
                                
Description

Exports the result of an SQL SELECT query (simple/join) in a TXT file, keeps IBM i original tabulations for a clear & quick overview of data.
The maximum size of a file is 1 million records. Multiple files are created when exporting more than 1 million records.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • sqlQuery string
    SQL SELECT query to execute
  • dirPath string
    Path of the directory to export files into, uses '\' directories delimiter and ens by '\'
  • outputFileName string
    Name of the resulting txt file without suffix
Returns
  • CopyToTXT() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string sqlQuery = "select * from libtest.tabletest";
string dirPath = "c:\txt\";
string outputFileName = "txtfile.txt";

//Function call
result = db2.CopyToTXT(connString, sessionID, licenseStatus, sqlQuery, dirPath, outputFileName);

//Returned results
result = "ASP0001 - Operation sucessful";
                                
Description

Exports the result of an SQL SELECT query (simple/join) in an Excel file (XLSX), recommended for up to a few thousands of records.
The maximum size of a file is 1 million records. Multiple files are created when exporting more than 1 million records.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • sqlQuery string
    SQL SELECT query to execute
  • dirPath string
    Path of the directory to export files into, uses '\' directories delimiter and ens by '\'
  • outputFileName string
    Name of the resulting xlsx file without suffix
Returns
  • CopyToXLSX() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string sqlQuery = "select * from libtest.tabletest";
string dirPath = "c:\xlsx\";
string outputFileName = "xlsxsheet.xslx";

//Function call
result = db2.CopyToXLSX(connString, sessionID, licenseStatus, sqlQuery, dirPath, outputFileName);

//Returned results
result = "ASP0001 - Operation sucessful";
                                
Description

Performs mass data extraction to CSV file. GetMassData retrieves detailed description of each fields in the header of the file.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • sqlQuery string
    SQL SELECT query (simple/join)
  • delimiter string
    CSV separator
  • nbrRec integer
    Number of records to extract
  • resultFilePath string
    Full path to the result file with suffix
  • chunk integer
    Chunking parameter affecting the overall speed of the process. Find more details here
Returns
  • GetMassData() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string sqlQuery = "select * from libtest.tabletest";
string delimiter = ";";
int nbrRec = 20000;
string resultFilePath = "c:\extractions\extract.csv";
int chunk = 500;

//Function call
result = db2.GetMassData(connString, sessionID, licenseStatus, sqlQuery, delimiter, nbrRec, resultFilePath, chunk);

//Returned results
result = "ASP0001 - Operation sucessful";
                                
Description

PutMassData uses a CSV file (with a separator). The CSV file must have values and types in the same position than the fields contained in the destination DB2 for i table. The separator must be an insignificant character on the CSV file values. An intermediate table with only one field must first be created in DB2 for i to receive the transferred data.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • txtField string
    Name of the single-field on the staging table/file
  • base string
    Database/library containing the staging table/file
  • table string
    Name of staging Table/file
  • docCsv string
    Full path of CSV File to send
  • delimiter string
    Delimiter
Returns
  • PutMassData() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string txtField = "field01";
string base = "libtest";
string table = "tabletest";
string docCsv = "c:\extractions\extract.csv";
string delimiter = ";";

//Function call
result = db2.PutMassData(connString, sessionID, licenseStatus, txtField, base, table, docCsv, delimiter);

//Returned results
result = "ASP0001 - Operation sucessful";
                                
Description

Automatically populates System.Web.TextBox controls with the first record returned by an SQL SELECT query (simple/join). TextBox controls ID's must be identical to fields names.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • keyField string
    key(s) field(s) of the file separated by a comma
  • sqlQuery string
    SQL SELECT query (simple/join)
Returns
  • GetFormattedData() string
    Data as XML String
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string keyField = "ID";
string sqlQuery = "select ID, NAME, AGE from LIBTEST.TABLETEST WHERE ID = '41587'";

//Function call
result = db2.GetFormattedData(connString, sessionID, licenseStatus, keyField, sqlQuery);

//Returned results
result = "<FormattedData>...</FormattedData>";
                                
Description

retrieves the result of an SQL SELECT query (simple/join) as an XML string.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • keyField string
    Complement to SQL ORDER BY statement. Fields separated by commas, can be followed by ASC or DESC (ex:'Field1 DESC, Field2, Field3 DESC')
  • sqlQuery string
    SQL SELECT query (simple/join)
  • nbrRec integer
    Number of records to extract
  • errMessage string
    Error/success message
Returns
  • GetAllRecords() string
    Data as XML string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string keyField = "ID";
string sqlQuery = "select ID, NAME, AGE from LIBTEST.TABLETEST WHERE age > 18";
int nbrRec = 2500;
string errMessage = "ASP0001 - Operation sucessful";

//Function call
result = db2.GetAllRecords(connString, sessionID, licenseStatus, keyField, sqlQuery, nbrRec, errMessage);

//Returned results
result = "";
                                
Description

retrieves all fields of the first record returned by an SQL SELECT query (simple/join), and the description of the fields (type, size, ...).

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • keyField string
    key(s) field(s) of the table separated by a comma
  • sqlQuery string
    SQL SELECT query (simple/join)
Returns
  • GetRecord() string
    List of string used to retrieve data

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string keyField = "NUMART";
string sqlQuery = "SELECT NUMART,DESART,DOMAIN FROM newrmf.tarticle WHERE NUMART='2TS4F07800001A'";

//Function call
result = db2.GetRecord(connString, sessionID, licenseStatus, keyField, sqlQuery);

//Returned results
result = "NUMART;2TS4F07800001A
DESART;YD.ZZN JUCK 185RC 46/51 33.47QQ
DOMAIN;2
===============================================
SELECT NUMART,DESART,DOMAIN FROM newrmf.tarticle WHERE NUMART='2TS4F07800001A'$§$NUMART$§$NUMART-A-NUMERO_ARTICLE$|$DESART-A-DESIGNATION$|$DOMAIN-A-CODE_DOMAINE$|$
32-0-A-NUMERO_ARTICLE-NUMERO ARTICLE......-0-NUMERO ARTICLE......-NUMART-Y-NUMART$|$64-0-A-DESIGNATION-DESIGNATION.........-0-DESIGNATION.........- - -DESART$|$1-0-A-CODE_DOMAINE-CODE DOMAINE........-0-CODE DOMAINE........- - -DOMAIN$|$
";
                                
Description

retrieves specified fields values of the first record returned by an SQL SELECT query (simple/join).

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • keyField string
    key(s) field(s) of the table separated by a comma
  • sqlQuery string
    SQL SELECT query (simple/join)
  • fieldName string
    this parameter contains the name of the field to retrieve
  • delimiter string
    Fields separator
  • sqlRef string
    SQL SELECT query providing the structure of the result, required in some cases, for instance when using FINAL TABLE statement.
Returns
  • GetRecordFields() string
    Fields values separated by the value of delimiter parameter as String
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string keyField = "ID";
string sqlQuery = "select * from FINAL TABLE (insert into LIBTEST.TABLETEST (NAME, AGE) VALUES ('JOHN', 45))";
string fieldName = "ID;NAME;AGE";
string delimiter = ";";
string sqlRef = "select ID, NAME, AGE from LIBTEST.TABLETEST";

//Function call
result = db2.GetRecordFields(connString, sessionID, licenseStatus, keyField, sqlQuery, fieldName, delimiter, sqlRef);

//Returned results
result = "1258;JOHN;45";
                                
Description

Counts records in the result of an SQL SELECT query (simple/join)

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • sqlQuery string
    SQL SELECT query from which to count (simple/join)
Returns
  • GetRecordCount() integer
    Number of records as Integer

//Parameters
Link2i db2 = new Link2i();
int result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string sqlQuery = "select * from LIBTEST.TABLETEST";

//Function call
result = db2.GetRecordCount(connString, sessionID, licenseStatus, sqlQuery);

//Returned results
result = 129000;
                                
Programs

These functions allow you to run existing IBM i programs from .NET environments, perform joint develoment and run ILE modules. You can also retrieve, edit and recompile programs using Excel/text files.

Description

RunProgram executes a program on the targeted IBM i without parameter.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • library string
    Name of the IBM i library/database that contains the program
  • pgmName string
    Name of the IBM i program to launch
Returns
  • RunProgram() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string library = "LIBTEST";
string pgmName = "PGMTEST";

//Function call
result = db2.RunProgram(connString, sessionID, licenseStatus, library, pgmName);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

RunProgramParam executes a program on the targeted IBM i with input parameters.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • library string
    Name of the IBM i library/database that contains the program
  • pgmName string
    Name of the IBM i program to launch
  • prmList string
    List of parameters values (input and output) as a list. More details about passing parameters here
  • prmLength string
    List of parameters sizes (input and output) as a list. More details about passing parameters here
  • delimiter string
    Delimiter used in parameter lists
Returns
  • RunProgramParam() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string library = "LIBTEST";
string pgmName = "PGMTEST";
string prmList = ""List of parameters values (input and output) as a list. More details about passing parameters here : www.knowledge.aumerial.com : String (ByVal)";
string prmLength = ""List of parameters sizes (input and output) as a list. More details about passing parameters here : www.knowledge.aumerial.com : String (ByVal)";
string delimiter = "Delimiter used in parameter lists: String (ByVal)";

//Function call
result = db2.RunProgramParam(connString, sessionID, licenseStatus, library, pgmName, prmList, prmLength, delimiter);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

RunProgram executes a program on the targeted IBM i with input and returned parameters.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • library string
    Name of the IBM i library/database that contains the program
  • pgmName string
    Name of the IBM i program to launch
  • prmList string
    List of parameters values (input and output) as a list. More details about passing parameters here
  • prmLength string
    List of parameters sizes (input and output) as a list. More details about passing parameters here
  • prmReturned string
    Position in prmList of the parameters to be returned. More details about passing parameters here
  • delimiter string
    Delimiter used in parameter lists
Returns
  • RunProgramParamReturn() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string library = "LIBTEST";
string pgmName = "PGMTEST";
string prmList = ""List of parameters values (input and output) as a list. More details about passing parameters here : www.knowledge.aumerial.com : String (ByVal)";
string prmLength = ""List of parameters sizes (input and output) as a list. More details about passing parameters here : www.knowledge.aumerial.com : String (ByVal)";
string prmReturned = ""Position in prmList of the parameters to be returned. More details about passing parameters here : www.knowledge.aumerial.com : String (ByVal)";
string delimiter = "Delimiter used in parameter lists: String (ByVal)";

//Function call
result = db2.RunProgramParamReturn(connString, sessionID, licenseStatus, library, pgmName, prmList, prmLength, prmReturned, delimiter);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

RunILEModule executes ILE module(s) on the targeted IBM i.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • library string
    Name of the IBM i library/database that contains the temporary program to run ILE module(s)
  • pgmName string
    Name of the IBM i temporary program
  • modules string
    List of ILE module(s) to run, in Library/Module form (from 1 to 300 modules separated by a space)
  • currentLib string
    Current library to run temporary program
  • additionalLib string
    Additional libraries (separator '$,$') referenced to run temporary program
Returns
  • RunILEModule() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string library = "LIBTEST";
string pgmName = "PGMTEST";
string modules = "MDLILE01 MDLILE02 MDLILE03 ";
string currentLib = "CURLIBTEST";
string additionalLib = "LIBTEST01$,$LIBTEST02";

//Function call
result = db2.RunILEModule(connString, sessionID, licenseStatus, library, pgmName, modules, currentLib, additionalLib);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

GetSourceXLSX retrieves a source file from the targeted IBM i as an XLSX file.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • base string
    Database/library whose members are to be listed
  • srcFile string
    Source file whose members are to be listed
  • member string
    Name of the member to export as an xlsx file
  • dirPath string
    Directory path where the source file has to be extracted on the Windows machine (uses '\' and must finish by '\')
  • outputFileName string
    Name of the excel file without suffix
Returns
  • GetSourceXLSX() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string base = "LIBTEST";
string srcFile = "QDDSSRC";
string member = "FILE001";
string dirPath = "c:\xlsx\";
string outputFileName = "Filetest01";

//Function call
result = db2.GetSourceXLSX(connString, sessionID, licenseStatus, base, srcFile, member, dirPath, outputFileName);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

GetSourceTXT retrieves a source file from the targeted IBM i as a text file.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • base string
    Database/library whose members are to be listed
  • srcFile string
    Source file whose members are to be listed
  • member string
    Name of the member to export as a text file
  • dirPath string
    Directory path where the source file has to be extracted on the Windows machine (uses '\' and must finish by '\')
  • outputFileName string
    Name of the text file without sufix
Returns
  • GetSourceTXT() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string base = "LIBTEST";
string srcFile = "QDDSSRC";
string member = "FILE001";
string dirPath = "c:\txt\";
string outputFileName = "Filetest01";

//Function call
result = db2.GetSourceTXT(connString, sessionID, licenseStatus, base, srcFile, member, dirPath, outputFileName);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

Copies a source member from an Excel file to the specified database/library and source file in the targeted IBM i. The Excel workbook to be applied must be formatted as a result file of GetSourceXLSX.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • base string
    Library/database where to post the source member
  • srcFile string
    Source file where to post the source member
  • member string
    Name of the new member
  • memberDescription string
    Short description of the new member (max 72 characters)
  • filePath string
    Full path of the Xlsx file (with suffix 'xlsx') of the member to send
  • srcType string
    Link2i predefined source type 'TypeSource' (RPG, CLP, PF...)
Returns
  • PostSource() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string base = "LIBTEST";
string srcFile = "QDDSSRC";
string member = "FILE001";
string memberDescription = "Customers file";
string filePath = "c:\xlsx\source01.xlsx";
string srcType = "Link2i.TypeSource.PF";

//Function call
result = db2.PostSource(connString, sessionID, licenseStatus, base, srcFile, member, memberDescription, filePath, srcType);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

RunStoredProcedureForNetCore runs an existing stored procedure on the targeted IBM i.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • library string
    Name of the targeted IBM i library/database that contains the stored procedure
  • prcName string
    Name of the IBM i stored procedure to launch
  • absoluteRec integer
    Occurence number to start reading
  • nbrRec integer
    Number of records to read
  • returnCursor string
    Value of returned data of stored procedure called
  • execCommit string
    Value indicating whether a Commit is necessary or not
  • prmDataType string
    List of predefined Link2i 'DB2ForiType' data types (_CHAR, _DECIMAL, _INTEGER...) matching the parameters values of prmDataList
  • prmDataList string
    List of parameters (input, output and inoutput) as a string list. For each output or inoutput list item, you must declare an empty value.
  • prmDirection string
    Directions (values 'IN', 'OUT', 'INOUT') matching prmDataList parameters as a list of string.
  • prmReturned string
    List of parameters values returned (OUT, INOUT) as a list of string. When calling the function, the list of string of the prmReturned parameter must have the same number of empty values as prmDataList.
Returns
  • RunStoredProcedureForNetCore() string
    Retrieves the result of a stored procedure as data in an XML string (if cursor request) and/ or a list of string containing the returned parameters values (added at the end of the XML string if existing).

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string library = "LIBTEST";
string prcName = "STPROC01";
int absoluteRec = 10;
int nbrRec = 120;
string returnCursor = "Y";
string execCommit = "Y";
string prmDataType = "{Link2i.DB2ForiType._Char, Link2i.DB2ForiType._Char, Link2i.DB2ForiType._Decimal, Link2i.DB2ForiType._Char}";
string prmDataList = "{"2TRAY31", "ZSZ NOD", "20", " "}";
string prmDirection = "{"IN", "IN", "IN", "OUT"}";
string prmReturned = "{" ", " ", " ", " "}";

//Function call
result = db2.RunStoredProcedureForNetCore(connString, sessionID, licenseStatus, library, prcName, absoluteRec, nbrRec, returnCursor, execCommit, prmDataType, prmDataList, prmDirection, prmReturned);

//Returned results
result = "";
                                
CL commands from .Net

Run CL commands from .NET

Description

Executes any CL command from .NET

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • cmd string
    Command to execute
Returns
  • RunCLCmd() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string cmd = ""CRTLIB LIB(LIBTEST) TEXT(LIBRARY TEST)"";

//Function call
result = db2.RunCLCmd(connString, sessionID, licenseStatus, cmd);

//Returned results
result = "ASP0001 - Operation successful";
                                
Using Excel

Use Excel as an input-output peripheral to manually create, edit or delete data

Description

Exports an Excel workbook that can be used to manually edit records, and posted back for update to the targeted IBM i using XlsxApply function.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • sqlQuery string
    SQL SELECT query to execute
  • orderByFields string
    Complement to SQL ORDER BY statement. Fields separated by commas, can be followed by ASC or DESC (ex:'Field1 DESC, Field2, Field3 DESC')
  • dirPath string
    Path of the directory to export files into, uses '\' directories delimiter and ends by '\'
  • outputFileName string
    Name of the resulting xlsx file without suffix
Returns
  • XlsxUpdate() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string sqlQuery = "select ID, NAME, AGE from LIBTEST.TABLETEST WHERE age > 18";
string orderByFields = "ID, NAME DESC";
string dirPath = "c:\xlsx\";
string outputFileName = "FileXlsx";

//Function call
result = db2.XlsxUpdate(connString, sessionID, licenseStatus, sqlQuery, orderByFields, dirPath, outputFileName);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

Composes an Excel workbook based on an SQL SELECT query that can be used to manually add records, and posted back for addition to the targeted IBM i using XlsxApply function.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • sqlQuery string
    SQL SELECT query to execute
  • orderByFields string
    Not necessary in creating mode. Complement to SQL ORDER BY statement. Fields separated by commas, can be followed by ASC or DESC (ex:'Field1 DESC, Field2, Field3 DESC')
  • dirPath string
    Path of the directory to export files into, uses '\' directories delimiter and ends by '\'
  • outputFileName string
    Name of the resulting xlsx file without suffix
Returns
  • XlsxCreate() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string sqlQuery = "select * from LIBTEST.TABLETEST";
string orderByFields = "" "";
string dirPath = "c:\xlsx\";
string outputFileName = "FileXlsx";

//Function call
result = db2.XlsxCreate(connString, sessionID, licenseStatus, sqlQuery, orderByFields, dirPath, outputFileName);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

Composes an Excel workbook based on an SQL SELECT query with a sample line that can be used to manually add records, and posted back for addition to the targeted IBM i using XlsxApply function.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • sqlQuery string
    SQL SELECT query to execute
  • orderByFields string
    Not necessary in creating mode. Complement to SQL ORDER BY statement. Fields separated by commas, can be followed by ASC or DESC (ex:'Field1 DESC, Field2, Field3 DESC')
  • dirPath string
    Path of the directory to export files into, uses '\' directories delimiter and ends by '\'
  • outputFileName string
    Name of the resulting xlsx file without suffix
Returns
  • XlsxCreateWithGeneric() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string sqlQuery = "select * from LIBTEST.TABLETEST";
string orderByFields = "" "";
string dirPath = "c:\xlsx\";
string outputFileName = "FileXlsx";

//Function call
result = db2.XlsxCreateWithGeneric(connString, sessionID, licenseStatus, sqlQuery, orderByFields, dirPath, outputFileName);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

Exports an Excel workbook that can be used to manually delete records and posted back for deletion to the targeted IBM i using XlsxApply function.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • sqlQuery string
    SQL SELECT query to execute
  • orderByFields string
    Complement to SQL ORDER BY statement. Fields separated by commas, can be followed by ASC or DESC (ex:'Field1 DESC, Field2, Field3 DESC')
  • dirPath string
    Path of the directory to export files into, uses '\' directories delimiter and ends by '\'
  • outputFileName string
    Name of the resulting xlsx file without suffix
Returns
  • XlsxDelete() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string sqlQuery = "select ID, NAME, AGE from LIBTEST.TABLETEST WHERE age > 18";
string orderByFields = "ID, NAME DESC";
string dirPath = "c:\xlsx\";
string outputFileName = "FileXlsx";

//Function call
result = db2.XlsxDelete(connString, sessionID, licenseStatus, sqlQuery, orderByFields, dirPath, outputFileName);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

Applies Excel workbooks generated by XlsxUpdate, XlsxCreate, XlsxCreateWithGeneric and XlsxDelete functions.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • resultFilePath string
    Full path of the file to apply, using '\' as directory delimiter
Returns
  • XlsxApply() string
    Error/success message as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string resultFilePath = "c:\xlsx\FileXlsx.xlsx";

//Function call
result = db2.XlsxApply(connString, sessionID, licenseStatus, resultFilePath);

//Returned results
result = "ASP0001 - Operation successful";
                                
Utility functions

These functions provide you with an out-of-the-box user interface to work with your data. Display and edit data from an ASP.NET page as you would do on a 5250 screen. Go further and exploit XML data to build your own user interfaces to master your data.

Description

Returns for display the first record resulting of an SQL SELECT Query (simple/join) as an XML string, for displaying only.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • keyField string
    key(s) field(s) of the table separated by a comma
  • sqlQuery string
    SQL SELECT query (simple/join)
Returns
  • UtilityDisplayGet() string
    Data formatted as XML string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string keyField = "KEYFLD";
string sqlQuery = "select ID, NAME, AGE from LIBTEST.TABLETEST WHERE ID=18";

//Function call
result = db2.UtilityDisplayGet(connString, sessionID, licenseStatus, keyField, sqlQuery);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

Returns for display the first record resulting of an SQL SELECT Query (simple) as an XML string, to manually edit records only.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • keyField string
    key(s) field(s) of the table separated by a comma
  • sqlQuery string
    SQL SELECT query with WHERE clause required. JOIN queries not allowed.
Returns
  • UtilityUpdateGet() string
    Data formatted as XML string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string keyField = "KEYFLD";
string sqlQuery = "select ID, NAME, AGE from LIBTEST.TABLETEST WHERE ID=18";

//Function call
result = db2.UtilityUpdateGet(connString, sessionID, licenseStatus, keyField, sqlQuery);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

Returns for display a blank record formatted according to an SQL SELECT Query (simple) as an XML string, to manually add records only.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • keyField string
    key(s) field(s) of the table separated by a comma
  • sqlQuery string
    SQL SELECT query with WHERE clause required. JOIN queries not allowed.
Returns
  • UtilityCreateGet() string
    Data formatted as XML string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string keyField = "KEYFLD";
string sqlQuery = "select ID, NAME, AGE from LIBTEST.TABLETEST WHERE ID=18";

//Function call
result = db2.UtilityCreateGet(connString, sessionID, licenseStatus, keyField, sqlQuery);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

Returns for display the first record resulting of an SQL SELECT Query (simple) as an XML string, to manually delete records only.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • keyField string
    key(s) field(s) of the table separated by a comma
  • sqlQuery string
    SQL SELECT query with WHERE clause required. JOIN queries not allowed.
Returns
  • UtilityDeleteGet() string
    Data formatted as XML string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string keyField = "KEYFLD";
string sqlQuery = "select ID, NAME, AGE from LIBTEST.TABLETEST WHERE ID=18";

//Function call
result = db2.UtilityDeleteGet(connString, sessionID, licenseStatus, keyField, sqlQuery);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

Applies altered XML String (updates a record) originally obtained by UtilityUpdateGet function.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • xmlStr string
    XML string returned by UtilityUpdateGet function
Returns
  • UtilityUpdatePost() string
    Error message on failure as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string xmlStr = "XML string returned by UtilityUpdateGet function";

//Function call
result = db2.UtilityUpdatePost(connString, sessionID, licenseStatus, xmlStr);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

Applies altered XML String (creates a new record) originally obtained by UtilityCreateGet function.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • xmlStr string
    XML string returned by UtilityCreateGet function
Returns
  • UtilityCreatePost() string
    Error message on failure as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string xmlStr = "XML string returned by UtilityCreateGet function";

//Function call
result = db2.UtilityCreatePost(connString, sessionID, licenseStatus, xmlStr);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

Applies altered XML String (deletes selected record) originally obtained by UtilityDeleteGet function.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • xmlStr string
    XML string returned by UtilityDeleteGet function
Returns
  • UtilityDeletePost() string
    Error message on failure as string

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string xmlStr = "XML string returned by UtilityDeleteGet function";

//Function call
result = db2.UtilityDeletePost(connString, sessionID, licenseStatus, xmlStr);

//Returned results
result = "ASP0001 - Operation successful";
                                
Description

retrieves a CL command builder as an XML string, used to compose a CL command prompt with a 5250-like interface in an ASP.NET web page.

Parameters
  • connString string
    LINK2i connection string (obtained with GetConnectionString function)
  • sessionID string
    Any 24 characters string. Can be user generated (random) or based on HTTP session id.
  • licenseStatus string
    Status of the current LINK2i licence in remaining days
  • cmd string
    CL command to get a prompt from
Returns
  • UtilityCLCmdGet() string
    Data formatted as XML string
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string connString = "Generated using GetConnectionString function";
string sessionID = "ab4cd89rf2thi47qzfl3641d";
string licenseStatus = "Valid license for 232 days for IBM i Number 78CFF40 - Partition Name S78CFF40";
string cmd = "CPYF";

//Function call
result = db2.UtilityCLCmdGet(connString, sessionID, licenseStatus, cmd);

//Returned results
result = "";
                                
Description

Generates a valid CL command ready to be executed using RunCLCmd function from a parameters chars string getting using the UtilityCLCmdGet function.

Parameters
  • clParametersStr string
    List of parameters in a chars string used to compose the CL command
Returns
  • UtilityCLCmdBuild() string
    A CL Command as String
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string clParametersStr = "CRTLIB| LIBTEST,*PROD,*LIBCRTAUT,1,*ASP,*SYSVAL,*SYSVAL,Test Library,|LIB,TYPE,AUT,ASP,ASPDEV,CRTAUT,CRTOBJAUD,TEXT,|-,-,-,-,-,-,-,-,|,*PROD,*LIBCRTAUT,1,*ASP,*SYSVAL,*SYSVAL,*BLANK,";

//Function call
result = db2.UtilityCLCmdBuild(clParametersStr);

//Returned results
result = "CRTLIB LIB(LIBTEST) TEXT(Test Library)";
                                
Data conversion

A set of utility functions for data conversion (date formats and ASCII/EBCDIC).

Description

Converts time from IBM i to .NET format.

Parameters
  • inputStr string
    String to translate from DB2 time to .NET time
Returns
  • ConvertTime() string
    Time as String
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string inputStr = "17:12:43";

//Function call
result = db2.ConvertTime(inputStr);

//Returned results
result = "17.12.43";
                                
Description

Converts date from IBM i to .NET format.

Parameters
  • inputStr string
    String to translate from DB2 date to .NET date
Returns
  • ConvertDate() string
    Date as String
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string inputStr = "2019-07-15";

//Function call
result = db2.ConvertDate(inputStr);

//Returned results
result = "15/07/2019";
                                
Description

Converts timestamp from IBM i to .NET format.

Parameters
  • inputStr string
    String to translate from DB2 timestamp to .NET time
Returns
  • ConvertTimeStamp() string
    TimeStamp as String
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string inputStr = "2019-07-15 17:12:43";

//Function call
result = db2.ConvertTimeStamp(inputStr);

//Returned results
result = "15/07/2019 17.12.43";
                                
Description

Converts EBCDIC string to ASCII

Parameters
  • inputStr string
    String to translate from ASCII to EBCDIC
Returns
  • ConvertEbcdicToAcscii() string
    Converted ASCII String
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string inputStr = "String © to process ;";

//Function call
result = db2.ConvertEbcdicToAcscii(inputStr);

//Returned results
result = "String © to process";
                                
Description

Converts EBCDIC string to ASCII without altering semicolumns ( ; )

Parameters
  • inputStr string
    CSV string to translate from ASCII to EBCDIC
Returns
  • ConvertEbcdicToAsciiCSV() string
    Converted ASCII String
    Error message on failure as String

//Parameters
Link2i db2 = new Link2i();
string result;
string inputStr = "String © to process ;";

//Function call
result = db2.ConvertEbcdicToAsciiCSV(inputStr);

//Returned results
result = "String © to process ;";