Aspose.Words.MailMerging.MailMerge.Execute(System.Data.IDataReader)

Here are the examples of the csharp api class Aspose.Words.MailMerging.MailMerge.Execute(System.Data.IDataReader) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

Project: Aspose.Words-for-.NET
Source File: ExMailMerge.cs
[Test]
        public void ExecuteDataReader()
        {
            //ExStart
            //ExFor:MailMerge.Execute(IDataReader)
            //ExSummary:Executes mail merge from an ADO.NET DataReader.
            // Open the template document
            Document doc = new Document(MyDir + "MailingLabelsDemo.doc");

            // Open the database connection.
            string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + DatabaseDir + "Northwind.mdb";
            OleDbConnection conn = new OleDbConnection(connString);
            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            // Open the data reader.
            OleDbCommand cmd = new OleDbCommand("SELECT TOP 50 * FROM Customers ORDER BY Country, CompanyName", conn);
            OleDbDataReader dataReader = cmd.ExecuteReader();

            // Perform the mail merge
            doc.MailMerge.Execute(dataReader);

            // Close database.
            dataReader.Close();
            conn.Close();

            doc.Save(MyDir + @"\Artifacts\MailMerge.ExecuteDataReader.doc");
            //ExEnd
        }