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

Free Support Forum - aspose.com

Merging word document with SQL data

Hello, Im using Aspose for merging word document with SQL data. And the engine we’ve done works just fine. We insert MergeFields in word document named exactly as columns returned from SQL procedure and we have no problem. The thing i wanna do now is show only certain text in word file. For example, I have a word document that displays some info about an employee and 3 tables. Is there a way to display only 2 tables or 1 table depending on a certain value given from SQL procedure? When inserting a field in word document i see there’s a IF field that can be inserted. Should i be using that IF field combined with a certain value returned from SQL procdure? If so, can u pls show me how? I’ve seen some examples on your forums like:
{IF {MERGERFIELD CCAMT5} > 0 “…”} but i dont really understand it. Any advice would be greatly apriciated. Thank you in advance!


This message was posted using Page2Forum from Document Builder - Aspose.Words Demos

Hi Igor,

Thanks for considering Aspose.

Sure, we will be glad to give some suggestions. Could you please post your template and code here so we can get a better idea of how things look. You can use an If field for this situation but it may be easier to use a handler.

Thanks,

Thanx for such a quick reply…
I’ve explained the problem in attached documents. There is a document that provides info about my problem and how i use MailMerge, also there is a word document that needs to be populated with data from SQL procedure and the last file is word document WITH populated data from SQL procedure.
Thanx…

Hi Igor,

Thanks for your detailed description and documents.

It seems in this case using IF fields are the best option. The reason they were not working properly in your document is that they were inserted as plain text instead of proper fields. I have sent a sample template to your inbox which works correctly for you to study.

If you need any further clarifications please feel free to ask.

Thanks,

Thank u for your quick and informative answer. You really made it clear how a word document and insert fields should be used. Your work and Aspose’s policy on dealing with customers problems is really commendable. Thanx again…