Creating AR invoiceline via API

I am having issues creating the invoice line via API with the code below can i have some guidace please. the line gets created and saved with no data(partnumber,Qty or discount)

internal void CreateInvLines(int invoice, int invoiceline, string part, decimal price, decimal discount, decimal qty, string comments)
{
string error = “”;

        try
        {

            svcInvoice.GetNewInvcDtl(ref dsInvoice, invoice);

            var dspart = new PartTableset();
            var newLine = dspart.Part.Cast<PartDataSet.PartRow>().Single(l => l.PartNum == part);

            var drInvoiceDtl = dsInvoice.InvcDtl.Last();
            drInvoiceDtl.PartNum = part;
            svcInvoice.OnChangeofLinePartNum(invoice, invoiceline, part, ref dsInvoice);
            drInvoiceDtl.LineDesc = newLine.PartDescription;
            svcInvoice.OnChangeofLineDesc(invoice, invoiceline, part,ref dsInvoice);
            drInvoiceDtl.OurOrderQty = qty;
            svcInvoice.OnChangeofLineQty(invoice, invoiceline, qty, ref dsInvoice);
            drInvoiceDtl.UnitPrice = price;
            drInvoiceDtl.DocUnitPrice = price;
            svcInvoice.OnChangeofLineUnitPrice(invoice, invoiceline, price, ref dsInvoice);
            drInvoiceDtl.DocDiscount = discount;
            drInvoiceDtl.Discount = discount;
            drInvoiceDtl.InvoiceComment = comments;
            svcInvoice.Update(ref dsInvoice);
        }
        catch (Exception ex)
        { error = "invoiceline" + ex.ToString(); }
        //return error;

    }

Did you follow the trace?

I did and the issue was the on a loop in another method thanks