Kbase P115786: .NET client generates "Specified cast is not valid" error when casting a .NET DataSet to a ProDatase
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/01/2008 |
|
Status: Verified
FACT(s) (Environment):
OpenEdge 10.x
SYMPTOM(s):
.NET client generates error when casting a .NET DataSet to a ProDataset
"Specified cast is not valid"
Using a strong typed DataSet which represents the proDataSet in the .NET client
CAUSE:
This is expected behavior. A .NET DataSet can not be casted to a ProDataSet.
FIX:
In order to work this limit around, the DataSet data can be written into a XML file, and the ProDataSet can write the data from this XML.
C# example:
// Create a .NET Dataset and loading XML schema from a proDataset
DataSet ds = new DataSet();
ds.ReadXmlSchema("C:\\Temp\\dsOrder.xsd");
// Adding a record in to the .NET Dataset
DataRow r = ds.Tables["ttOrder"].NewRow();
r["CustNum"] = 1;
ds.Tables["eOrder"].Rows.Add(r);
// Dump data into the dsORder.xml file
ds.WriteXml("C:\\dsOrder.xml");
// Read data from dsOrder.xml into the strong type named proDataSet
dsOrder prods = new dsOrder();
prods.ReadXml("c:\\dsOrder.xml");
// Display content of the table ttOrder in the Datagrid
dataGrid1.DataSource = prods.Tables[0];