Problems creating multiple douments

I am trying to create multiple documents all of the same Word template file. I have logic that goes through a loop to create each one individuall and them combine them into a single document. The problem is that the single creation does not work. It creates the same document again and again. Therefore, the combine logic does not work either. I am sure I am doing something wrong, I just don’t know what. Can someone please advise. Code snippets follow. Btw, I am passing parameters to a query but I checked to make sure the retrieval arguments are unique.

This is the main logic:

private void buildDocument(Boolean batchMode)
{
    destinationDocument = new Document();
    //batch or single?
    if (batchMode == true)
    {
        //traverse XML tree
        XmlNodeList nodelist = xmlDocument.GetElementsByTagName("Parameter");
        foreach (XmlNode node in nodelist)
        {
            //open the source document
            string sourceFileName = "C:\\LANOV3.DOC";
            sourceDocument = new Document(sourceFileName);
            //build it
            string novID = getValue(node, "novid");
            generateNOV(novID);
            appendDoc(destinationDocument, sourceDocument);
        }
        destinationDocument.Save("C:\\FINISHED2.DOC");
    }

This is the function that builds the individual reports:
This is the code to build a single document.

    private void generateNOV(string novID)
    {
        //dynamimc where clause
        string hdrWhereClause, detailWhereClause;
        //datareader
        IDataReader dataReader = null;
        //massage where
        hdrWhereClause = "WHERE NOTICE_OF_VIOLATION.NOTICE_OF_VIOLATION_ID =" + "'" + novID + "'";
        //build header query
        OleDbCommand headerCmd = new OleDbCommand(
        "SELECT NOTICE_OF_VIOLATION.NOTICE_OF_VIOLATION_ID AS NOVID, NOTICE_OF_VIOLATION.NOTICE_OF_VIOLATION_DATE AS VIOLATIONDATE, " +
        "NOTICE_OF_VIOLATION.SERVED_TO_NAME AS SERVEDTONAME, NOTICE_OF_VIOLATION.SERVED_TO_TITLE AS TITLE, " +
        "NOTICE_OF_VIOLATION.SERVED_TO_DRIVERS_LICENSE AS LICENSENUMBER, NOTICE_OF_VIOLATION.COMMENTS, " +
        "NOTICE_OF_VIOLATION.RESPONSE_DUE_DATE, NOTICE_OF_VIOLATION.PERMIT_S, NOTICE_OF_VIOLATION.IND_ID, " +
        "NOTICE_OF_VIOLATION.INSPECTOR_L_S, FACILITY.FACILITY_ID AS FACILITYID, PERMIT.PERMIT_NUM AS PERMITNUM, " +
        "FACILITY.IND_NAME AS FACILITYNAME, INSPECTOR_L.INSPECTOR AS INSPECTOR, INSPECTOR_L.PHONE AS INSPECTORPHONE, " +
        "ADDRESS.ADDRESS_L_S, ADDRESS.STREET_NAME AS STREETNAME, ADDRESS.STREET_NUM AS STREETNUM, ADDRESS.STREET_PREFIX AS STREETPREFIX, ADDRESS.STREET_SUFFIX AS STREETSUFFIX, " +
        "ADDRESS.STREET_UNIT_NUM STREETUNITNUM, ADDRESS.CITY AS CITY, ADDRESS.STATE_L_S, ADDRESS.ZIP AS ZIP, STATE_L.STATE AS STATE " +
        "FROM ADDRESS INNER JOIN " +
        "FACILITY ON ADDRESS.IND_ID = FACILITY.IND_ID LEFT OUTER JOIN " +
        "STATE_L ON ADDRESS.STATE_L_S = STATE_L.STATE_L_S RIGHT OUTER JOIN " +
        "NOTICE_OF_VIOLATION INNER JOIN " +
        "PERMIT ON NOTICE_OF_VIOLATION.PERMIT_S = PERMIT.PERMIT_S ON FACILITY.IND_ID = PERMIT.IND_ID AND " +
        "FACILITY.IND_ID = NOTICE_OF_VIOLATION.IND_ID FULL OUTER JOIN " +
        "INSPECTOR_L ON NOTICE_OF_VIOLATION.INSPECTOR_L_S = INSPECTOR_L.INSPECTOR_L_S AND " +
        "PERMIT.INSPECTOR_L_S = INSPECTOR_L.INSPECTOR_L_S AND FACILITY.SENIOR_INSPECTOR_L_S = INSPECTOR_L.INSPECTOR_L_S AND " +
        "FACILITY.INSPECTOR_INSPECTOR_L_S = INSPECTOR_L.INSPECTOR_L_S " +
        "WHERE (NOTICE_OF_VIOLATION.NOTICE_OF_VIOLATION_ID = '2KOOL4U') AND (ADDRESS.ADDRESS_L_S = 1)", conn);
        //get data
        dataReader = headerCmd.ExecuteReader();
        //populate doc
        sourceDocument.MailMerge.ExecuteWithRegions(dataReader, "NOVHeader");
        //massage where
        detailWhereClause = "WHERE NOTICE_OF_VIOLTN__VIOLTN.NOTICE_OF_VIOLATION_ID =" + "'" + novID + "'";
        //build detail querty
        OleDbCommand detailCmd = new OleDbCommand(
        "SELECT VIOLATION.VIOLATION_DATE AS ViolationDate, SNC_CATEGORY_L.SNC_CATEGORY_DESC AS SNCDescription, VIOLATION.VIOLATION_DESC AS ViolationDesc, " +
        "SNC_CATEGORY_DETAIL_L.SNC_CATEGORY_DETAIL AS SNCDetail, SNC_CATEGORY_DETAIL_L.SNC_CATEGORY_DETAIL_DESC AS SNCDetailDesc, " +
        "NOTICE_OF_VIOLTN__VIOLTN.NOTICE_OF_VIOLATION_ID AS ViolationID " +
        "FROM VIOLATION INNER JOIN " +
        "SNC_CATEGORY_DETAIL_L ON VIOLATION.SNC_CATEGORY_DETAIL_L_S = SNC_CATEGORY_DETAIL_L.SNC_CATEGORY_DETAIL_L_S INNER JOIN " +
        "NOTICE_OF_VIOLTN__VIOLTN ON VIOLATION.VIO_ID = NOTICE_OF_VIOLTN__VIOLTN.VIO_ID LEFT OUTER JOIN " +
        "SNC_CATEGORY_L ON SNC_CATEGORY_DETAIL_L.SNC_CATEGORY_L_S = SNC_CATEGORY_L.SNC_CATEGORY_L_S AND " +
        "VIOLATION.VIO_OR_SNC_CAT_L_S = SNC_CATEGORY_L.SNC_CATEGORY_L_S " + detailWhereClause, conn);
        //get data
        dataReader = detailCmd.ExecuteReader();
        //populate doc
        sourceDocument.MailMerge.ExecuteWithRegions(dataReader, "NOVDetails");
        sourceDocument.Save("C:\\SINGLE.DOC");
        //cleanup
        dataReader.Close();
    }

Why does SINGLE.DOC keep showing the same report over and over again?

Here is what you are doing in your code.

You are creating an empty destination document, then entering a loop. In the loop you are opening “LANOV3.DOC”, generate and save “SINGLE.DOC” based on a data in XML, and then append “LANOV3.DOC” to destination document. In the end you save destination document to file “FINISHED2.DOC”.

The result is that in “FINISHED2.DOC” you have “LANOV3.DOC” content duplicated n times. And in SINGLE.DOC you have the content generated after the last XML node in the loop.

That does not make much sense. So what you need is to review and change the logic in code.

I understand I don’t have the correct logic. That is why I am asking. I don’t understand how Aspose works when trying to combine docments.

I would need some assistance in this area please. In psuedocode, this is what I want to be able to do. Can some one please suggest the actual code as it pertains to the Aspose logic?

All I want to be able to do is:

a.) Save off individual copies of the documents produced in the loop
b.) Save off a document that contains ALL the documents in the loop

I have consulted your CombneDocs example but require further assistance. Pointing out that my logic is wrong is not that helpful. I already know that. If I knew how to change, I would not have asked.

Thank you for your time.

while not end of XML
parm = xml.parm
singleDoc = createSingleDocument(parm)
combineDocuments(singleDoc, masterDoc)
end loop

If it is helpful, I might further add that LAN3NOV.DOC is a merge template. I have to open it in order to tell Aspose what document to use when I use ExecuteMailMergeWithRegions(…).

Sorry, we don’t provide assistance in writing general application code for our customers. Please contact Aspose.Service team if you require assistance in designing and coding your application.

The complete overview of Aspose Services Program can be seen here:
https://about.aspose.com/