Share via


Sample : Executing i-series CL commands using Host file Provider - MSHostFileClient.dll

Control language (CL) REFERENCES:

https://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/rbam6/rbam6clmain.htm

C# sample :

using

System;

using System.Collections.Generic;

using

System.Text;

using

Microsoft.HostIntegration.MsHostFileClient;

namespace

ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

//connectionstring

string connectionstring = "Provider=SNAOLEDB;User ID=USERID;Password=PASSWORD;APPC Remote LU Alias=RUSDFM;APPC Local LU Alias=P31680;APPC Mode Name=PA62TKNU;Network Transport Library=TCP;Host CCSID=37;PC Code Page=1252;Network Address=HOST;Network Port=PORTNUMBER;Process Binary as Character=False;Persist Security Info=True;Cache Authentication=False;Cache Authentication=False;Encrypt Password=False;Impersonation Level=Impersonate;Location=HOST;Protection Level=Connect;Default Library=USERID;Repair Host Keys=False;Strict Validation=False;Mask Password=False;";

HostFileConnection cn = new HostFileConnection(connectionstring);

try

{

cn.Open();

HostFileCommand cmd = new HostFileCommand("EXEC 'SNDMSG MSG(HELLO) TOUSR(USERID)'", cn);

string RESULT = (string)cmd.ExecuteScalar();

// the result is dependednt upon the command getting executed.

// if command is wrong , it will give syntax error and will not execute at all.

if (RESULT.Equals(string.Empty))

{

// check for result to determine successfull execution of command.

}

}

catch (Exception e)

{

}

finally

{

cn.Close();

}

}

}

}