Kbase P158860: How to pass a TABLE-HANDLE as an OUTPUT or INPUT parameter from a .NET open client using OpenAPI
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  02/08/2010 |
|
Status: Unverified
GOAL:
How to pass a Table handle as INPUT parameter in .NET using OpenAPI
GOAL:
How to pass a TABLE-HANDLE as an OUTPUT parameter from a .NET open client using OpenAPI
GOAL:
How to call an internal procedure with an TABLE-HANDLE OUTPUT parameter in .NET using OpenAPI
FACT(s) (Environment):
Windows
OpenEdge 10.x
FIX:
See below a C# code which:
- Passes a Table handle as OUTPUT parameter
- Adds one record into the Table
- Passes back the Table handle as INPUT parameter
using Progress.Open4GL.DynamicAPI;
using Progress.Open4GL.Proxy;
using Progress.Open4GL;
/* ..... */
Connection con = new Connection("AppServer:\\localhost:5162\asbroker1", "", "");
con.SessionModel = 1;
OpenAppObject ao = new OpenAppObject(con, "");
OpenProcObject pro = ao.CreatePO("test.p");
DataTable ttCust = new DataTable("ttCust");
// Create the ParamArray
ParamArray paramProc = new ParamArray(1);
// Pass the Table handle as OUTPUT parameter
paramProc.AddTableHandle(0, null, ParamArrayMode.OUTPUT, null);
pro.RunProc("getCustomer", paramProc);
// Retrieve the returned Temp-table
ttCust = (DataTable)paramProc.GetOutputParameter(0);
// Display the temp-table into a dataGridView
dataGridView1.DataSource = ttCust;
paramProc.Clear();
// Create the TableMetaData
TempTableMetaData ttMetaData = new TempTableMetaData("ttCust", null,ttCust.Columns.Count,false,0,null,null,null);
// Add a row in the temp-table to be passed
DataRow r = ttCust.NewRow();
r[0] = 1000;
r[1] = "New Customer";
ttCust.Rows.Add(r);
// Pass Table handle as INPUT parameter
paramProc.AddTableHandle(0, ttCust, ParamArrayMode.INPUT, ttMetaData);
pro.RunProc("setCustomer", paramProc);