Hi Robert,
Some points about your code:
When you do this:
objsalesinvoice.Lines.BaseLine = 1
objsalesinvoice.Lines.BaseEntry = 8
objsalesinvoice.Lines.BaseType = 15
You said to the DI API to copy the line index 1 from the DeliveryNotes when the docentry is 8.
With this code you doesn't need execute any query, because this code copy all values presents in the line index 1 from your deliveryNotes to your invoice.
if you don't want copy the values from the deliveryNotes you cannot set this properties that I mentioned above. You just set the values that you want about your itens that you need in your invoice.
I didn't understand why you made a query under INV1, because INV1 is the invoice line, do you want copy values from another invoice? If yes, I suggest you to use a repetition structure in your code , because your query can returns one or more rows.
A sample:
while(!rs1.EOF)
{
rs1.MoveNext();
}
Hope it helps.
Regards,
Diego