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

Free Support Forum - aspose.com

Mail merge is not working for sql datasousr

SqlDataAdapter cmd = new SqlDataAdapter();
SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings[“ConstrTS”]);
protected void Page_Load(object sender, EventArgs e)
{
cn.Open();
string sql = “select * from task_assign_user”;
cmd = new SqlDataAdapter(sql, cn);
DataTable pizzaDs = new DataTable();
cmd.Fill(pizzaDs);

// Note: The Datatable.TableNames and the DataSet.Relations are defined implicitly by .NET through ReadXml.
// To see examples of how to set up relations manually check the corresponding documentation of this sample
// pizzaDs.ReadXml(dataDir + “CustomerData.xml”);

// Open the template document.
Document doc = new Document(Server.MapPath("~/doc/1.docx"));

// Execute the nested mail merge with regions
doc.MailMerge.Execute(pizzaDs);

// Save the output to file
doc.Save(Server.MapPath("~/doc/2.docx"));
}


Please check the above code…

Hi Chimay,

Thanks for your inquiry. Could you please attach your input and output Word documents here for testing? I will investigate the issue on my side and provide you more information.

I have attached the file.Please help…

I have to print multiple line items…

Hi Chimay,

Thanks for sharing the detail. You are using mail merge with regions. Please use MailMerge.ExecuteWithRegions method instead of MailMerge.Execute. Please read following documentation for your kind reference.
http://www.aspose.com/docs/display/wordsnet/Mail+Merge+with+Regions+Explained
http://www.aspose.com/docs/display/wordsnet/How+to++Execute+Mail+Merge+with+Regions

Please let us know if you have any more queries.