开发者

relation-table in dataset always returns 0 rows

I have created a strongly typed dataset in the VS 2005 Dataset Designer. There are two tables that relates to each other in a one to many relationship: Claim and ClaimDetail. The designer automatically creates a function GetClaimDetailRows which returns all ClaimDetailRows for a ClaimRow. Why is this Array's length always 0? Because ClaimDetail contains more than 40 Million rows, i did'nt fill it before i call GetClaimDetailRows but had configured it's selectcommand that it takes a parameter idData to fill only the related records. But that seems not to work because the ClaimDetail-Datatable is empty.

relation-table in dataset always returns 0 rows

(source: bilder-hochladen.net)

The automaticaly generated function in the ClaimRow-Class which returns all related ClaimDetailRows:

        Public Function GetClaimDetailRows() As ClaimDetailRow()
            If (Me.Table.ChildRelations("Claim_ClaimDetail") Is Nothing) Then
                Return New ClaimDetailRow(-1) {}
            Else开发者_JAVA技巧
                Return CType(MyBase.GetChildRows(Me.Table.ChildRelations("Claim_ClaimDetail")),ClaimDetailRow())
            End If
        End Function

When debugging i see that it jumps into the else block but returns 0 rows. Do i have to fill the Claimdetail-Datatable first(ClearBeforeFill=True) for each Claim? But then i dont need to use this function anymore.

UPDATE: I now fill the Datatable(ClearBeforeFill=True)before i call the Child-function and it works. But i dont understand why it could not throw an exception(optionally) when i try to acess a child-relation without having that datatable being filled(at least with 0 rows). Instead of that it returns 0 rows what can be correct or incorrect and is difficult to detect. Is this a lack of design or am i missing something?


Because the generated GetChildRows() assumes (all) the child records are loaded into memory.

You'll have to write some code in the client part (Form). You can use the BindingSource.CurrentChanged and fill the appropriate records into the child table.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜