Board index » Visual Studio » Find vs FindRow help

Find vs FindRow help

Visual Studio336
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


-
 

Re:Find vs FindRow help

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





"Brad" <ballison@ukcdogs.com>wrote in message

Quote
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









-

Re:Find vs FindRow help

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





"Brad" <ballison@ukcdogs.com>schreef in bericht

Quote
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









-