D
Dean Slindee
This chunk of code does not translate accurately using the available C# to
VB translator tools.
I am wondering what the "sub within a sub" structure should look like in VB:
starting with the
"public void Fill(DataSet ds)" and "tds = this;" statements. (Sorry, the
indentation did not come across).
Thanks for looking,
Dean Slindee
using System;
using System.Data;
using System.Xml;
namespace Rosters
{
public class TypedDataSet: roster
{
private TypedDataSet tds;
public void Fill(XmlDocument doc)
{
// First populate an untyped DataSet with the xml document
DataSet ds = new DataSet();
byte [] buf = System.Text.ASCIIEncoding.ASCII.GetBytes(doc.OuterXml);
System.IO.MemoryStream ms = new System.IO.MemoryStream(buf);
ds.ReadXml(ms);
ms.Close();
// Then fill the typed DataSet from the untyped DataSet
Fill(ds);
}
public new void ReadXml(string xmlFile)
{
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(xmlFile);
this.Fill(xmlDoc);
}
catch (XmlException)
{
// ignore or handle exception here
}
public void Fill(DataSet ds)
{
tds = this;
// Map each row of each table in the untyped DataSet to a
// corresponding item in the strongly typed DataSet
for ( int i = 0; i < ds.Tables.Count; i++ )
{
foreach (DataRow iDr in ds.Tables.Rows)
{
DataRow oDr = tds.Tables.NewRow();
for ( int j = 0; j < ds.Tables.Columns.Count; j++ )
try
{
oDr[j] = iDr[j].ToString();
}
catch (NoNullAllowedException)
{
// ignore for now - just in
// case no such column in DataSet
}
tds.Tables.Rows.Add(oDr);
}
}
tds.AcceptChanges();
}
}
}
VB translator tools.
I am wondering what the "sub within a sub" structure should look like in VB:
starting with the
"public void Fill(DataSet ds)" and "tds = this;" statements. (Sorry, the
indentation did not come across).
Thanks for looking,
Dean Slindee
using System;
using System.Data;
using System.Xml;
namespace Rosters
{
public class TypedDataSet: roster
{
private TypedDataSet tds;
public void Fill(XmlDocument doc)
{
// First populate an untyped DataSet with the xml document
DataSet ds = new DataSet();
byte [] buf = System.Text.ASCIIEncoding.ASCII.GetBytes(doc.OuterXml);
System.IO.MemoryStream ms = new System.IO.MemoryStream(buf);
ds.ReadXml(ms);
ms.Close();
// Then fill the typed DataSet from the untyped DataSet
Fill(ds);
}
public new void ReadXml(string xmlFile)
{
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(xmlFile);
this.Fill(xmlDoc);
}
catch (XmlException)
{
// ignore or handle exception here
}
public void Fill(DataSet ds)
{
tds = this;
// Map each row of each table in the untyped DataSet to a
// corresponding item in the strongly typed DataSet
for ( int i = 0; i < ds.Tables.Count; i++ )
{
foreach (DataRow iDr in ds.Tables.Rows)
{
DataRow oDr = tds.Tables.NewRow();
for ( int j = 0; j < ds.Tables.Columns.Count; j++ )
try
{
oDr[j] = iDr[j].ToString();
}
catch (NoNullAllowedException)
{
// ignore for now - just in
// case no such column in DataSet
}
tds.Tables.Rows.Add(oDr);
}
}
tds.AcceptChanges();
}
}
}