none
passing a parameter to fillby RRS feed

  • Question

  • I am trying to dynamically populate a binding navigator with selected pieces of a dataset that occur in real time.

    The fillby statement is:

    SELECT        record_item, category, item_date, data_item_1, data_item_2, data_item_3, data_item_4, data_item_5, picture_name, ID
    FROM            records
    WHERE        (category = '@mycategory')
    ORDER BY record_item

    category is a string variable

    my fillby statement is as follows:

     Me.RecordsTableAdapter.FillBy(Me.ContactsDataSet.records, ComboBoxCategory.Text)

    the error is:

    “too many arguments to ‘public  override  Overloads function fillby(data Table as ContactsDataSet.recordsDataTable) as integer’

    I am using VB 2012.  I cannot see what I am doing wrong.

    Suggestions?


    RONATMOODYLAKE

    • Moved by Amanda Zhu Friday, September 13, 2013 8:39 AM
    Thursday, September 12, 2013 1:05 AM

Answers

  • You are wrong.  The dialog above misses the point completely.  If you read what I was trying to do you will see that I was trying to pass a parameter to the FillBy method.  The error was in the select portion of the query builder:

    WHERE        (category = '@mycategory')

    It should have been:

    WHERE        (category = ?)

    This nonsense about overriding the FillBy method was COMPLETELY IRRELEVANT!  It cost me 2 days of work. The:

    FillBy(ComboBoxCategory.Text) suggestion doesn't work. After the (above) change was made in the query builder, the original statement

     FillBy(Me.ContactsDataSet.records, ComboBoxCategory.Text) works perfectly.


    RONATMOODYLAKE

    Sunday, September 15, 2013 1:04 AM
  • Sorry Ron. We had no way of knowing which database you were using, consequently there was no way to know that you specified your parameters wrong in your query for the TableAdapter. 

    If you are not using SqlServer, then "WHERE category = ?" would be the correct way to specify your query.

    However, if you *are* using SqlServer then I believe there was a slight mistake in your original query, "where category = @mycategory", which should have been "where category = @category". Sorry that I missed that one (of course, that's a moot point if you're not using SqlServer).

    ~~Bonnie Berent DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Sunday, September 15, 2013 5:12 AM

All replies

  • Hello,

    I have moved this thread to ADO.NET DataSet forum for better response.

    Best regards,


    Amanda Zhu <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, September 13, 2013 8:40 AM
  • Hello,

    Thanks for visiting this forum.

    For this issue “too many arguments to ‘public override Overloads function fillby(data Table as ContactsDataSet.recordsDataTable) as integer’”, I do not know whether you have override the method Fillby().In the code, it was given two parameters, however the fillby() just needs one parameter.

    So please check if you have override the method Fillby().

    If this do not work for you, could you please share more information regarding the program so that we could help you better?

    Thanks&Regards.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



    Friday, September 13, 2013 10:10 AM
    Moderator
  • I have used the wizard in ContactsDataSet.xsd to build the Fillby method.  The following is an exact copy from the wizard (It should take one parameter - category:

    SELECT        record_item, category, item_date, data_item_1, data_item_2, data_item_3, data_item_4, data_item_5, picture_name, ID
    FROM            records
    WHERE        (category = '@mycategory')
    ORDER BY record_item

    Is this clear?  I do not know what you mean by override the mothod Fillby(), so I did not do it.

    The paremeter I want to use is the text in the combo box ComboBoxCategory.Text.

    The calling code is:

        Private Sub ComboBoxCategory_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxCategory.SelectedIndexChanged
            If ComboBoxCategory.Text = "All" Then
                Me.RecordsTableAdapter.Fill(Me.ContactsDataSet.records)
            Else
                Me.RecordsTableAdapter.FillBy(Me.ContactsDataSet.records, ComboBoxCategory.Text)
            End If
        End Sub

    The error is in the "else" statement.  Please show what I did wrong or explain this override thing so I can get this to work.

    Thanks.


    RONATMOODYLAKE

    Friday, September 13, 2013 1:46 PM
  • Hi,

    With the error "too many arguments to ‘public  override  Overloads function as integer’", we can know that the function Fillby() needs just one parameter that is ContactsDataSet.recordsDataTable type.

    However, it was given two parameter.

    Me.RecordsTableAdapter.FillBy(Me.ContactsDataSet.records, ComboBoxCategory.Text)

    So it needs to be changed to be:

    Me.RecordsTableAdapter.FillBy(Me.ContactsDataSet.records)

    And I notice that you want to use ComboBoxCategory.Text as a parameter,too.

    Because the FillBy() only has one parameter, so you need to override the FillBy() function to have two parameters as below:

    fillby(data Table as ContactsDataSet.recordsDataTable, test as string)  
    Regards.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Friday, September 13, 2013 3:08 PM
    Moderator
  • Sorry.  I still do not understand.  Where should I declare the overload function?:

    fillby(data Table as ContactsDataSet.recordsDataTable, test as string)

    Should I add this to the wizard section? Should I declare it in the calling code?



    RONATMOODYLAKE

    Friday, September 13, 2013 9:01 PM
  • I am still stuck.  I tried this code:

        Private Sub ComboBoxCategory_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxCategory.SelectedIndexChanged
            If ComboBoxCategory.Text = "All" Then
                Me.RecordsTableAdapter.Fill(Me.ContactsDataSet.records)
            Else
                FillBy(Me.ContactsDataSet.records, ComboBoxCategory.Text)
            End If
        End Sub
        Overloads Sub FillBy(dataTable As ContactsDataSet.recordsDataTable, test As String)
            Me.RecordsTableAdapter.FillBy(Me.ContactsDataSet.records, test)
        End Sub

    I still get the error: too many arguments to public...

    What am I doing wrong?  Please help.


    RONATMOODYLAKE

    Saturday, September 14, 2013 1:33 PM
  • The FillBy()  method that the TableAdapter generated doesn't take the DataTable as a parameter. The method that takes the DataTable is the .Fill() method. So your code should look like this:

     If ComboBoxCategory.Text = "All" Then
       Me.RecordsTableAdapter.Fill(Me.ContactsDataSet.records)
    Else
       FillBy(ComboBoxCategory.Text)
    End If


    ~~Bonnie Berent DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Saturday, September 14, 2013 4:23 PM
  • You are wrong.  The dialog above misses the point completely.  If you read what I was trying to do you will see that I was trying to pass a parameter to the FillBy method.  The error was in the select portion of the query builder:

    WHERE        (category = '@mycategory')

    It should have been:

    WHERE        (category = ?)

    This nonsense about overriding the FillBy method was COMPLETELY IRRELEVANT!  It cost me 2 days of work. The:

    FillBy(ComboBoxCategory.Text) suggestion doesn't work. After the (above) change was made in the query builder, the original statement

     FillBy(Me.ContactsDataSet.records, ComboBoxCategory.Text) works perfectly.


    RONATMOODYLAKE

    Sunday, September 15, 2013 1:04 AM
  • Sorry Ron. We had no way of knowing which database you were using, consequently there was no way to know that you specified your parameters wrong in your query for the TableAdapter. 

    If you are not using SqlServer, then "WHERE category = ?" would be the correct way to specify your query.

    However, if you *are* using SqlServer then I believe there was a slight mistake in your original query, "where category = @mycategory", which should have been "where category = @category". Sorry that I missed that one (of course, that's a moot point if you're not using SqlServer).

    ~~Bonnie Berent DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Sunday, September 15, 2013 5:12 AM