Hello everyone, here's my problem! I'm using the .NET framework v1.1...
I've created a strongly-typed dataset class (using XML), and I've
instantiated it twice. The first instance is used to hold a
mainframe-generated text file. The second instance is used to hold the
results from a database query. Unfortunately, the text file uses a
combination primary key of (branch ID, account number). However, my
database has no need for branch ID- it's driven purely by account number.
Of course, I've used SQL to sort my database query by account number. To
sort the file's dataset, I set up the DataSet.DataTable.DefaultView.Sort =
"account ASC". But in my main loop, the DataRow returned by using
DataSet.DataTable.DefaultView[i].Row has lost all of the strongly-typed
features that I had gained by defining an XSD class.
Is there a method/property that I've missed, which will allow me to walk the
objects "backwards" from the DefaultView[i] in order to get the actual
source row (with strong typing) from the DataSet?
Here's a sample of the structure/main loop and what I'd like to do.:
public class otherClass{
//this class belongs to the database operations
private MyStronglyTypedDataset dsDatabase;
private int iIndex;
public bool matchFound(String strAccount)
{ //loop based on iIndex++ to find match in dsDatabase }
public MyStronglyTypedDataset.tblRow foundRow {get...}
public void compareXMLds(MyStronglyTypedDataset.tblRow sourceRow)
{ //compares dsDatabase.mytable.Rows[iIndex] with sourceRow,
//and generates report }
}
public class MainClass {
//this is for linking the TextFile's class with the database's class
MyStronglyTypedDataset ds = loadTextFileClass.resultingDataSet;
for (int i=0; i<(ds.tbl.Count); i++)
{
//what I need is inside the asterisks below
if otherClass.matchFound(ds.mytable.DefaultView[i][mykey].ToString())
otherClass.compareXMLds(**ds.mytable[i]**)
}
}
There must be something in ADO.NET that keeps a link between the DataView's
row and the underlying DataTable's row- how do I get to it? I'm wishing for
something like:
MyStronglyTypedDataset.tblRow sourceRow =
ds.mytable.DefaultView[i].getSourceRowBack;
It has crossed my mind to create a "temporary" sorted text file based off of
the source file... but I'd rather not go that route- it reminds me of my
Pascal days!
Thanks!
-Thomas H