Find vs FindRow help

B

Brad

I have a quandry which hopefully is easy for most.

I have a table that represents about 5,000 genetic dog records. This data
is being extracted from an AS400 database. Each dog's record includes the
Sire and the Dam number which is also contained somewhere within the main
table.

What I need to do is to find the name of the Sire and/or the Dam instead of
just giving the primary key record as it is currently stored. Here is what
I need to do:

1) Fill the dataset
2) If the Sire or Dam have a number, then I need to look at this same
dataset table and pull in that dog's name.
3) Save the modified row to a textfile stream

What would be the best way to perform the second process? Would I copy the
dataset's table to a dataview? I tried this and I thought that the Find
function would return the actual row number, it it returns -1. Or should I
use table.rows.find ? Except the information being pulled in from the AS400
does no have a primary key.

Make any sense? If so, thanks for any help.

Brad
 
C

Chris, Master of All Things Insignificant

You could use the DataTable.Select(Where Clause Here) method. This will
return a subset of DataRow(). You can then loop through and write out the
records. Hope this helps.

Chris
 
C

Cor Ligthert

Brad,

I thinkk as first idea that I would go for the dataview (by the way that is
not a copy it is just a view over your table).

With the datarowview I think it can be something as.

\\\\Not tested .
dv.RowFilter = "Sire = X and Dam = Y"
Dim sw As New IO.StreamWriter("path")
For i As Integer = 0 To dv.Count - 1
Dim sb As New System.Text.StringBuilder
For y As Integer = 0 To dv.Table.Columns.Count - 1
sb.Append(dv(i)(y).ToString) 'this is ofcourse not what you do
Next
sw.writeline(sb.ToString)
Next
///

I hope this gives an idea

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top