I am tearing my hair out over this one.  We have a database that
basically models some xml documents (long story).  I have an Element
table that has ElementID as its primary key, a nullable ParentID that is
a self join foreign key to the ElementID field, and other descriptive
fields that are not material.  I then have a Attributes table, which has
an AttributeID field as its primary key, and has a corresponding
ElementID field that is a foreign key to the Element table.  An Element
can have multiple attributes, but each attribute can have only one
element, so it is analytically indistinguishable from a traditional
Customer/Orders situation.



I created a strongly typed dataset incorporating these tables among
others.  I have the primary key constraints identified above, and the
foreign key constraints identified.  I have two list boxes, one with the
Elements listed, and the other for the Attributes that belong to a
selected Element.  When a user clicks on a particular Element, I capture
the ElementID, which is the DataValue field for the list box, use the
ElementTable.FindByID method to get the data row for the Element, and
then call the .GetAttributeRows method for that element data row.  Code
follows:



Dim intID As Integer = lbElements.SelectedValue

        Dim dt As TestDataset.ElementDataTable = ds.Element

        Dim drElement As TestDataset.ElementRow =
dt.FindByElementID(intID)

        If drElement.HasAttribute = False Then

            MsgBox("No attributes for this element.",
MsgBoxStyle.Information, "Attribute Check")

        End If

        Dim drAttribute As TestDataset.AttributeRow() =

        Try

            drAttribute = drElement.GettempAttributeRows

        Catch ex As ConstraintException

            Console.WriteLine(ex.Message)

        Catch ex As Exception

            Console.WriteLine(ex.Message)

        End Try

        With lbAttributes

            .DataSource = drAttribute

            .DisplayMember = "AttributeName"

            .ValueMember = "AttributeID"

        End With

    End Sub



I am not capturing any errors, yet the row array is empty.  There are
rows in the dataset table that should be returned.  Any ideas?



Thanks,



Jeff




===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to