Search code examples
c#asp.netdatasettableadapter

The best overloaded method match for... has some invalid arguments


I am using DataAdapter("SDM_Tran_GenerateInvoice") inside DataSet("SDMDAL.xsd") in my project.

Below is the structure of DataAdapter along with the Stored Procedure names in it: enter image description here

Below is the Table structure Im using for the same: enter image description here

I am calling this DataAdapter inside Class file named as SDM.InvoiceBLL.cs:

using SDMDALTableAdapters;

public class SDM_Invoice
{
    private SDM_Tran_GenerateInvoiceTableAdapter _GenerateInvoiceTableAdapter = null;
    protected SDM_Tran_GenerateInvoiceTableAdapter Adapter
    {
        get
        {
            if (_GenerateInvoiceTableAdapter == null)
                _GenerateInvoiceTableAdapter = new SDM_Tran_GenerateInvoiceTableAdapter();

            return _GenerateInvoiceTableAdapter;
        }
    }

    #region GET
    //to show data in Invoice Grid
    public SDMDAL.SDM_Tran_GenerateInvoiceDataTable SelectInvoice(string _SPID)
    {
        return Adapter.SelectInvoice(_SPID);
    }
    //to show data in 1st hidden Grid
    public SDMDAL.SDM_Tran_GenerateInvoiceDataTable GetInvoiceBillingBySPID(string _SPID)
    {
        return Adapter.GetInvoiceBillingBySPID(_SPID);
    }
    //to fetch InvoiceID for unique key generation
    public SDMDAL.SDM_Tran_GenerateInvoiceDataTable GetInvoiceID()
    {
        return Adapter.GetInvoiceID();
    }
    //to fetch InvoiceNumber for unique key generation
    public SDMDAL.SDM_Tran_GenerateInvoiceDataTable GetInvoiceNumber()
    {
        return Adapter.GetInvoiceNumber();
    }
    #endregion   

    public string Insert(string InvoiceID, string SPfoID, string InvoiceLineNo, string InvoiceNo, string InvoiceType, string BillingIDfoID, string BusinessUnit, string DirectCost, string InvfoStatusID, string Status, DateTime Date, string AccountCode)
    {
        string query = Convert.ToString(Adapter.Insert1(InvoiceNo, SPfoID, InvoiceLineNo, InvoiceNo, InvoiceType, BillingIDfoID, BusinessUnit, DirectCost, InvfoStatusID, Status, Date, AccountCode));
        return query;
    }

    public SDM_Invoice()
    {

    }
}

and then calling the "Insert" function of class file inside Default.aspx.cs page, to save records on button click:

 protected void btnInvoice_Click(object sender, EventArgs e)
{
    generateInvoiceId();
    generateInvoiceNumber();

    string InvType = rlbInvType.SelectedValue;
    string Status = "Draft";

    string BillingID;
    string DirectCost;
    string BusinessUnit;
    string StatusID;

    string AccCode;

    foreach (GridDataItem itm in rgData.Items)
    {
        BillingID = itm["BillingID"].Text;
        DirectCost = itm["DCIDescription"].Text;
        BusinessUnit = itm["BUName"].Text;
        StatusID = itm["BUfoStatusID"].Text;

        Label lb = (Label)itm.FindControl("Label1");
        string InvLineNo = lb.Text;

        try
        {
            SDM.Invoice.Insert(lblInvId.Text, _SPID, InvLineNo, lblInvNo, InvType, BillingID, BusinessUnit, DirectCost, StatusID, Status, DateTime.Now, AccCode);
        }
        catch (Exception ex)
        {

        }
    }
}

I rebuilt my project number of times and when I run my web page "Default.aspx.cs", always it gives me below error:

The best overloaded method match for 'SDM_Invoice.Insert(string, string, string, string, string, string, string, string, string, string, System.DateTime, string)' has some invalid arguments

I searched many articles related to my issue but couldn't find any solution for my problem.

This is the first time I am working with TableAdapter.
Please help me what is wrong in my code ? What am I missing in it.
Thanks in advance.


Solution

  • All the arguments except for the next to last need to be strings, but you seem to be passing some non-string values, for example lblInvNo, which seems to be a user interface element.

    Check the type of each argument aside from the next to last, and make sure they are all strings.