We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Execute followed by ExecuteWithRegions

I have a stored proc that returns two result sets. This code works great:

SqlDataReader reader = cmd.ExecuteReader();
doc.MailMerge.ExecuteWithRegions(reader, "Master");
reader.NextResult();
doc.MailMerge.ExecuteWithRegions(reader, "Details");

However, since the Master area is not repeating, I took out the TableStart:Master/TableEnd:Master fields and changed that to use Execute. But then the Details table does not get filled in.

SqlDataReader reader = cmd.ExecuteReader();
doc.MailMerge.Execute(reader);
reader.NextResult();
doc.MailMerge.ExecuteWithRegions(reader, "Details");

Does Execute(SqlDataReader) already iterate through all the result sets? Why the difference?

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for your inquiry. Could you please explain me what you are trying to achieve? Also please attach your template document and document that will show me the result that you need to get.

If you put DataReader into the Execute method whole section will be repeated for each record in your reader.

Best regards.

The app works fine using this code:

Dim reader As SqlDataReader = cmd.ExecuteReader()
doc.MailMerge.ExecuteWithRegions(reader, "Project")
reader.NextResult()
doc.MailMerge.ExecuteWithRegions(reader, "Recommendations")
reader.NextResult()
doc.MailMerge.Execute(reader)

My only problem was that when I use Execute(reader) for the first section as it is not a repeating section, there was never any data in other sections. Yet using Start/End table it works fine.

The stored proc returns 3 result sets: one header row, then detail rows, then a footer row.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I think that this occurs because ExecuteWithRegions method fills only one region in the document. But if you run Execute method first there could be several regions with same name (I mean TableStart/End:name). In this case only first region will be filled with data. So you should run ExecuteWithRegions and then run Execute method.

Best regards.