locked
TableAdapter RRS feed

  • Question

  • User-305496339 posted
    Below is the code thats giving me an error   
    
    
    Dim adapter As New DataSetTableAdapters.SentEmailTableAdapter
    Dim table As New DataSet.SentEmailDataTable
    adapter.GetDataByDate(table, batchflag, startdate, enddate)
    
    Value of type 'DataSet.SentEmailDataTable' cannot be converted to 'String'.
    
    Too many arguments to 'Public Overridable Overloads Function GetDataByDate(BatchFlag As String, StartDate As Date?, EndDate As Date?) As DataSet.SentEmailDataTable'.	
    
    
    
    But this code works with no error. As you can see I pass it a table and one parameter.
    
    Dim adapter As New DataSetTableAdapters.EmployeesTableAdapter
    Dim table As New DataSet.EmployeesDataTable
    adapter.GetDataByRegion(table, state)

    Tuesday, November 12, 2019 7:57 PM

Answers

  • User665608656 posted

    Hi rkrex,

    According to your description, do you want to get the data source of the database first, then filter the data and bind it to RDLC?

    Is the FillByState here your custom method?

    If so, when you successfully get the data source you need, assign the data source to the corresponding ReportViewer control.

    You can refer to the following code:

      Using cn As New SqlConnection(gcs)
            cn.Open()
            Dim sa As New SqlDataAdapter(sql, cn)
            sa.SelectCommand.CommandTimeout = cGlobals.ReportTimeout
            sa.Fill(ds, "Foos")
        End Using
        bs.DataSource = ds
        bs.DataMember = "Foos"
        Dim rds As New ReportDataSource
        rds.Name = "dsFooList_Foos"
        rds.Value = bs
        rv1.LocalReport.DataSources.Add(rds)
    
        Me.Show()
        rv1.RefreshReport()

    If my understanding is wrong, please describe your requirements in detail and provide us with details of your customized methods for reference.

    Best Regards,

    YongQing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 14, 2019 2:28 AM

All replies

  • User475983607 posted

    The error and method signature is very clear.  The GetDataBydate does not have an overload signature that matches your calling code.  Take a moments to review your custom code.

    Tuesday, November 12, 2019 8:13 PM
  • User665608656 posted

    Hi rkrex,

    Value of type 'DataSet.SentEmailDataTable' cannot be converted to 'String'.
    
    Too many arguments to 'Public Overridable Overloads Function GetDataByDate(BatchFlag As String, StartDate As Date?, EndDate As Date?) As DataSet.SentEmailDataTable'.	
    

    According to the error message, this indicates that the actual parameter you are passing does not match the formal parameter type. In the method GetDataByDate, the first parameter is string type, while you are actually passing datatable type.

    The normal working code you mentioned below, the method you call is GetDataByRegion, which is not the same as the method you have error in.

    Please confirm the construction of these methods and their parameter types to ensure that the parameter types you passed in are correct.

    didn't worked code:

    adapter.GetDataByDate(table, batchflag, startdate, enddate)
    GetDataByDate(BatchFlag As String, StartDate As Date?, EndDate As Date?)

    worked code:

    adapter.GetDataByRegion(table, state)

    Best Regards,

    YongQing.

    Wednesday, November 13, 2019 7:11 AM
  • User-305496339 posted

    I'm not sure if either one of these replies are correct, but I appreciate the help. Anyway, what I discovered is that I need to use the fill method for the adapter; that's why it didn't like those arguments. For example,

    Dim adapter As New DataSetTableAdapters.tbl_EmployeeTableAdapter

    Dim table As New DataSet.tbl_EmployeeDataTable

    adapter.FillByState(table, state)

    But if you know of any good examples where someone used a table adapter with an rdlc report where they also passed multiple data parameters using a url query string, then that is what I am trying to accomplish. Thanks !!!

    Wednesday, November 13, 2019 5:45 PM
  • User665608656 posted

    Hi rkrex,

    According to your description, do you want to get the data source of the database first, then filter the data and bind it to RDLC?

    Is the FillByState here your custom method?

    If so, when you successfully get the data source you need, assign the data source to the corresponding ReportViewer control.

    You can refer to the following code:

      Using cn As New SqlConnection(gcs)
            cn.Open()
            Dim sa As New SqlDataAdapter(sql, cn)
            sa.SelectCommand.CommandTimeout = cGlobals.ReportTimeout
            sa.Fill(ds, "Foos")
        End Using
        bs.DataSource = ds
        bs.DataMember = "Foos"
        Dim rds As New ReportDataSource
        rds.Name = "dsFooList_Foos"
        rds.Value = bs
        rv1.LocalReport.DataSources.Add(rds)
    
        Me.Show()
        rv1.RefreshReport()

    If my understanding is wrong, please describe your requirements in detail and provide us with details of your customized methods for reference.

    Best Regards,

    YongQing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 14, 2019 2:28 AM
  • User-305496339 posted

    Thanks this lends a lot of clarity to solving the problem. I was wondering if you could tell me why you chose the sqldataadapter over the table adapter or is one basically the predecessor of the other? Thanks !

    Thursday, November 14, 2019 4:33 PM