Execute and ExecuteWithRegions

Hello,

I’m sorry to ask this question which should be already answered, but I don’t find the answer.
My problem is:
I would like put differents data with a ExecuteWithRegions linked to others data found by a simple Execute.

For exemple if I based my probleme to the sample SaleInvoiceDemo, I would like to generate a Word document for the Orders 10444 and 10445 and 10446 with their details.
Actually I try to make SQL Request with “Where OrderID>10443 And OrderID<10447” It’s working for each order (simple Exectue) but I get the details of all orders; and not only for the order selected (normal).

Idea May I need to use a DataSet ???

Thanks for Help.
Francois

Here my code:

{


doc.MailMerge.Execute(GetTestOrder());
DataView orderDetails = new DataView(GetTestOrderDetails());
orderDetails.Sort = “ExtendedPrice DESC”;
doc.MailMerge.ExecuteWithRegions(orderDetails);
}
 

private DataTable GetTestOrder()
{
DataTable table = base.ExecuteDataTable(string.Format(“SELECT * FROM AsposeWordOrders WHERE OrderID>10443 And OrderID<10447”));
table.TableName = “Orders”;

return table;
}

private DataTable GetTestOrderDetails()
{
DataTable table = ExecuteDataTable(string.Format(“SELECT * FROM AsposeWordOrderDetails WHERE OrderID>10443 And OrderID<10449 ORDER BY ProductID”));
table.TableName = “OrderDetails”;

return table;
}

Hi Francois,

Thank you for considering Aspose.

If I have understood your problem correctly, this solution would help:


for (int i = 0; i < 3; i++)
{
DataView orderDetails = new DataView(GetTestOrderDetails(10444 + i));
orderDetails.Sort = “ExtendedPrice DESC”;
doc.MailMerge.ExecuteWithRegions(orderDetails);
}



private DataTable GetTestOrderDetails(int orderID)
{
DataTable table = ExecuteDataTable(string.Format(
“SELECT * FROM AsposeWordOrderDetails WHERE OrderID={0}”, orderID));
table.TableName = “OrderDetails”;
return table;
}

(The code still can be optimized by selecting the whole range of the order details at once and subsequent filtering).

Does this suit you?

Perfect,

That is exactly what I want to do.
I try to do it like that, first, but with a simple execute in the for loop.

Thanks you !!!