Foxpro Question

  • Thread starter Thread starter Pete Kane
  • Start date Start date
P

Pete Kane

Hello there, just been thrown in the deep end with .NET, I need to perform
the equivalent of "Set Relation" using CSharp and ADO.NET on two Foxpro
tables. My basic needs are: Open two Foxpro tables, relate them using two
common fields, scan through every record ( loads of logic goes here... )
create and write to an output table. I know how to open, read, and write,
but am at a loss as to how to join them on their common fields ( or if it's
possible !?)

any help much appreciated
Regards,
Peter J. Kane
 
Peter,

This is easy. First, you want to load the data from the two tables into
DataTable instances in the same data set (you have to do this because data
in .NET is not ambient, like it is in FoxPro, but I believe you know this).

Once you do that, you can create DataRelation instances which indicate
which table is the parent, which is the child, and the fields that are used
to bind the two tables.

Then, while cycling through the rows in the parent table, you can call
the GetChildRows method on the DataRow, passing in the DataRelation object,
and it will give you the records in the child table that are related to that
row in the parent table.

Hope this helps.
 
thanks Nicholas, very helpful

Nicholas Paldino said:
Peter,

This is easy. First, you want to load the data from the two tables into
DataTable instances in the same data set (you have to do this because data
in .NET is not ambient, like it is in FoxPro, but I believe you know this).

Once you do that, you can create DataRelation instances which indicate
which table is the parent, which is the child, and the fields that are used
to bind the two tables.

Then, while cycling through the rows in the parent table, you can call
the GetChildRows method on the DataRow, passing in the DataRelation object,
and it will give you the records in the child table that are related to that
row in the parent table.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Pete Kane said:
Hello there, just been thrown in the deep end with .NET, I need to perform
the equivalent of "Set Relation" using CSharp and ADO.NET on two Foxpro
tables. My basic needs are: Open two Foxpro tables, relate them using two
common fields, scan through every record ( loads of logic goes here... )
create and write to an output table. I know how to open, read, and write,
but am at a loss as to how to join them on their common fields ( or if
it's
possible !?)

any help much appreciated
Regards,
Peter J. Kane
 
Back
Top