I've got a dataset (ratesds2) containing multiple relational tables
(3) for which I'd like to find a single child record.

Table(1) contains a single record for each product and table(2)
contains details for the product. The product details table is
"nested" based on the productID. Table one has a single key field
(productID) and table two has two key fields with productID from table
1 being one of the two and the other a unique product attribute key.
Dataset is correctly defined with the two primary key fields in table
2.

All I want to do is retrieve a specific row from table 2 given the two
key fields as follows and put the value of a single field into string
variable;

Sample Code
-----------------------------------------------
Dim filterstring As String = "productid = '123'"

Dim productdetailsview As New DataView
productdetailsview = ratesds2.Tables(2).DefaultView
productdetailsview.RowFilter = filterstring

Dim foundRowsc() As DataRowView = productdetailsview.Find(New
Object() "123", "C"})

dim attribiute_c as string = foundRowsc(0)("Details")

This doesn't work. Any ideas?

Re: .Find Method w/multiple keys by Joe

Joe
Fri Jul 25 21:58:08 CDT 2003

Dim findTheseVals(1) As Object

For Each mRow In dt1.Rows
findTheseVals(0) = mRow("KeyField1")
findTheseVals(1) = mRow("KeyField2")
foundRow = dt2.Rows.Find(findTheseVals)

If foundRow Is Nothing Then

--
Joe Fallon




"DDW" <ddwakeham@yahoo.com> wrote in message
news:bb118083.0307251308.90551fd@posting.google.com...
> I've got a dataset (ratesds2) containing multiple relational tables
> (3) for which I'd like to find a single child record.
>
> Table(1) contains a single record for each product and table(2)
> contains details for the product. The product details table is
> "nested" based on the productID. Table one has a single key field
> (productID) and table two has two key fields with productID from table
> 1 being one of the two and the other a unique product attribute key.
> Dataset is correctly defined with the two primary key fields in table
> 2.
>
> All I want to do is retrieve a specific row from table 2 given the two
> key fields as follows and put the value of a single field into string
> variable;
>
> Sample Code
> -----------------------------------------------
> Dim filterstring As String = "productid = '123'"
>
> Dim productdetailsview As New DataView
> productdetailsview = ratesds2.Tables(2).DefaultView
> productdetailsview.RowFilter = filterstring
>
> Dim foundRowsc() As DataRowView = productdetailsview.Find(New
> Object() "123", "C"})
>
> dim attribiute_c as string = foundRowsc(0)("Details")
>
> This doesn't work. Any ideas?



Re: .Find Method w/multiple keys by Derek

Derek
Wed Aug 06 09:54:51 CDT 2003

It is possible to build a composite PK/Unique key DataColumn...

Derek LaZard

"DDW" <ddwakeham@yahoo.com> wrote in message
news:bb118083.0307251308.90551fd@posting.google.com...
> I've got a dataset (ratesds2) containing multiple relational tables
> (3) for which I'd like to find a single child record.
>
> Table(1) contains a single record for each product and table(2)
> contains details for the product. The product details table is
> "nested" based on the productID. Table one has a single key field
> (productID) and table two has two key fields with productID from table
> 1 being one of the two and the other a unique product attribute key.
> Dataset is correctly defined with the two primary key fields in table
> 2.
>
> All I want to do is retrieve a specific row from table 2 given the two
> key fields as follows and put the value of a single field into string
> variable;
>
> Sample Code
> -----------------------------------------------
> Dim filterstring As String = "productid = '123'"
>
> Dim productdetailsview As New DataView
> productdetailsview = ratesds2.Tables(2).DefaultView
> productdetailsview.RowFilter = filterstring
>
> Dim foundRowsc() As DataRowView = productdetailsview.Find(New
> Object() "123", "C"})
>
> dim attribiute_c as string = foundRowsc(0)("Details")
>
> This doesn't work. Any ideas?



Re: .Find Method w/multiple keys by Ron

Ron
Thu Aug 07 07:45:04 CDT 2003

DDW,
Find will work only against the primary key of the table. You can use
select on the table to get an Array of DataRows matching the criteria. Just
use (in my approximate VB translation)
Dim dataRows as DataRow()
dataRows = ratesds2.Tables(2).Select("(productid = '123') AND (the rest of
the criteria)")
If the search is specific enough you will just get one item in the array.

I'd probably use String.Format to build the criteria easily from parameters
in code.

Ron Allen

"DDW" <ddwakeham@yahoo.com> wrote in message
news:bb118083.0307251308.90551fd@posting.google.com...
> I've got a dataset (ratesds2) containing multiple relational tables
> (3) for which I'd like to find a single child record.
>
> Table(1) contains a single record for each product and table(2)
> contains details for the product. The product details table is
> "nested" based on the productID. Table one has a single key field
> (productID) and table two has two key fields with productID from table
> 1 being one of the two and the other a unique product attribute key.
> Dataset is correctly defined with the two primary key fields in table
> 2.
>
> All I want to do is retrieve a specific row from table 2 given the two
> key fields as follows and put the value of a single field into string
> variable;
>
> Sample Code
> -----------------------------------------------
> Dim filterstring As String = "productid = '123'"
>
> Dim productdetailsview As New DataView
> productdetailsview = ratesds2.Tables(2).DefaultView
> productdetailsview.RowFilter = filterstring
>
> Dim foundRowsc() As DataRowView = productdetailsview.Find(New
> Object() "123", "C"})
>
> dim attribiute_c as string = foundRowsc(0)("Details")
>
> This doesn't work. Any ideas?