Cannot create a child list for field...

Lornar

New member
Joined
Oct 8, 2007
Messages
2
Programming Experience
Beginner
I'm using VB.NET 2003, and have created a simple Windows Form, connected to a single SQL db table, with a single data adapter and dataset.
When I try to debug I receive this error:

An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll

Additional information: Cannot create a child list for field VendorNo.

:(
Here's the code:
VB.NET:
Private Sub btnVendor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVendor.Click
        'Populates the DataSet
        OleDbDataAdapter1.SelectCommand.Parameters("VendorNo").Value = txtVendor.Text
        ItemDataSet.Clear()
        OleDbDataAdapter1.Fill(ItemDataSet)
        ShowPosition()
    End Sub

    Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
        Me.BindingContext(ItemDataSet, "VendorNo").Position -= 1
        ShowPosition()
    End Sub

    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
        Me.BindingContext(ItemDataSet, "VendorNo").Position += 1
        ShowPosition()
    End Sub
    Private Sub ShowPosition()
        Dim iCnt As Integer
        Dim iPos As Integer
 iCnt = Me.BindingContext(ItemDataSet, "VendorNo").Count
        If iCnt = 0 Then
            txtPosition.Text = "(No Records)"
        Else
            iPos = Me.BindingContext(ItemDataSet, "VendorNo").Position + 1
            txtPosition.Text = iPos.ToString & " of " & iCnt.ToString
        End If
    End Sub
AND, this is where it stops:
iCnt = Me.BindingContext(ItemDataSet, "VendorNo").Count

Help!
Thanks
Lorna
 
Last edited by a moderator:
You have no DataTable in your DataSet named "VendorNo". If you want to populate a named DataTable then you have to specify that. This:
VB.NET:
OleDbDataAdapter1.Fill(ItemDataSet)
populates an unnamed table. If you want to populate a table named "VendorNo" then you have to say so:
VB.NET:
OleDbDataAdapter1.Fill(ItemDataSet, "VendorNo")
 
TY, that changed things.

I no longer receive the error, (TY again!) BUT now I have a different problem.
When I enter my Vendor No, it fills the "Show Position" field, but does not display any of the "1 of 9" records it lists.
 
Back
Top