Kbase P121690: How to map the .NET DateTime data type to Progress DateTime when passing dynamic DataSet from .NET O
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  25/06/2008 |
|
Status: Unverified
GOAL:
How to map the .NET DateTime data type to Progress DateTime when passing dynamic Dataset from .NET Open Client to the AppServer
GOAL:
Example of code showing how to use the SetColumnProType static method
FACT(s) (Environment):
OpenEdge 10.x
Windows
FIX:
When passing a dynamic dataset from a .NET client to the AppServer and the DataTables contain .NET System.DateTime fields, each fields needs to be mapped to the Progress DateTime data type. Otherwise, the AppServer receives the DateTime field as Date data type.
That is the reason why each DateTime field of a DataTable needs to mapped to the Progress DateTime data type by invoking the SetColumnProType static method.
See below a C# sample:
// AppServer Connection
Connection con = new Connection("AppServer://localhost:5162/asbroker1","","","");
aoDateTime ao = new aoDateTime(con);
// Temp-Table definitions
System.Data.DataTable hTT= new System.Data.DataTable();
hTT.Columns.Add("ID",typeof(int));
hTT.Columns.Add("StartDaTe",typeof(DateTime));
hTT.Columns.Add("DueDaTe",typeof(DateTime));
hTT.Columns.Add("EndDaTe",typeof(DateTime));
// Map .NET DateTime to Progress DateTime
ProDataTable.SetColumnProType(hTT, "StartDaTe", Parameter.PRO_DATETIME);
ProDataTable.SetColumnProType(hTT, "DueDaTe", Parameter.PRO_DATETIME);
ProDataTable.SetColumnProType(hTT, "EndDaTe", Parameter.PRO_DATETIME);
// Add a row in the DataTable hTT1
DataRow r = hTT.NewRow();
r["ID"] = 1234;
r["StartDT"] = DateTime.Now;
r["DueDT"] = DateTime.Now;
r["EndDT"] = DateTime.Now;
hTT.Rows.Add(r);
// Create Dataset
Dataset hDS = new Dataset("DataSet1");
hDS.Tables.Add(hTT);
// Send Dataset to Progress
// sendDateTime is an ABL procedure with a Dynamic ProDataSet input parameter
ao.sendDateTime(hDS);
// Release Objects
ao.Dispose();
con.Dispose();