Free Support Forum - aspose.com

Merged field aint working

Merge fields aren't replaced/filled in by the data from the table

DataTable Objecten = base.ExecuteSQLDataTable("SELECT * FROM objecten where ob_pr_id = 27");
for (int i = 0; i < Objecten.Rows.Count; i++)
{
Document objectDoc = srcDoc.Clone();

DataRow ObjectRow = Objecten.Rows[i];
objectDoc.MailMerge.Execute(ObjectRow);

DocumentBuilder builderObj = new DocumentBuilder(objectDoc);

InsertDocument(builder.CurrentParagraph, srcDoc);
}

In the document I added the following merged fields:
«ob_naam»
«ob_omschrijving»

I have set a breakpoint at objectDoc.MailMerge.Execute(ObjectRow);
The objectRow contains the folling data

ItemArray {Dimensions:[12]} object[]
[0] 46 object {int}
[1] "Vernieuwing betonblokjes in Hemtunnelbuizen TL" object {string}
[2] 27 object {int}
[3] 1 object {int}
[4] "139" object {string}
[5] "172.416" object {string}
[6] "172.416" object {string}
[7] "oms" object {string}
[8] "" object {string}
[9] 1 object {int}
[10] 1 object {int}
[11] 1 object {int}

And the following columns
List Count = 12 System.Collections.ArrayList
[0] {ob_id} object {System.Data.DataColumn}
[1] {ob_naam} object {System.Data.DataColumn}
[2] {ob_pr_id} object {System.Data.DataColumn}
[3] {ob_volgorde} object {System.Data.DataColumn}
[4] {ob_geocode} object {System.Data.DataColumn}
[5] {ob_vankm} object {System.Data.DataColumn}
[6] {ob_totkm} object {System.Data.DataColumn}
[7] {ob_omschrijving} object {System.Data.DataColumn}
[8] {ob_locatie} object {System.Data.DataColumn}
[9] {ob_aantalwerkgevers} object {System.Data.DataColumn}
[10] {ob_aantalzelfstandige} object {System.Data.DataColumn}
[11] {ob_aantalwerknemers} object {System.Data.DataColumn}

What i am doing wrong?


This message was posted using Aspose.Live 2 Forum

Hi

Thanks for your inquiry. I think that in this case you should use mail Merge with Regions. I think that the following code should work for you.

DataTable Objecten = base.ExecuteSQLDataTable("SELECT * FROM objecten where ob_pr_id = 27");

srcDoc.MailMerge.doc.MailMerge.ExecuteWithRegions(Objecten);

Also try using attached template with this code.

Best regards.

Thanks,

I think I have to solve it with an builder.insert, because I need information from other tabels aswell.
Hoped I could solve it the easy way :-).

Regards,