Problem of Merge field used with ExecuteRegions


#1

Hello,

I have a problem where I am using Execute as well as ExecuteByRegions.
There’s one field in Execute which repeats as if its part of the ExecuteByRegions. Please see the source code below. Pl see attached the Word doc generated. I am talking about the ‘Terms and Conditions below’ phrase which comes from a textbox in the page. I even removed the Merge field from the Template. But not only that it shows up still in the doc but also repeats. Since I can attach only one doc I am not attaching the template. Let me know if you need it.


MyCommand = New OleDb.OleDbDataAdapter(strSQL, MyConnection)

DS = New DataSet()

MyCommand.Fill(DS, “MYETARIFFRATES”)

If DS.Tables(“MYETARIFFRATES”).Rows.Count > 0 Then

doc.MailMerge.ExecuteWithRegions(DS)

End If

DS.Clear()

MyCommand.Dispose()

strSQL = “SELECT CUSTCODE,CUST_NAME,CONTACT_NAME,DEPT,Add1,CITY,STATE,COUNTRY,ZIPCODE,PHONE,”

strSQL += “TELEFAX FROM TARIFFCUSTMAST WHERE CUSTCODE=’” & txtCust.Text & “’”

Dim myComm As New OleDb.OleDbCommand(strSQL, MyConnection)

Dim myReader As OleDb.OleDbDataReader

MyConnection.Open()

myReader = myComm.ExecuteReader()

Dim CUSTCODE, CUST_NAME, CONTACT_NAME, DEPT, Add1, CITY, STATE, COUNTRY, ZIPCODE, PHONE, TELEFAX

While myReader.Read

CUST_NAME = myReader(1)

CONTACT_NAME = myReader(2)

DEPT = myReader(3)

Add1 = myReader(4)

CITY = myReader(5)

STATE = myReader(6)

COUNTRY = myReader(7)

ZIPCODE = myReader(8)

PHONE = myReader(9)

TELEFAX = myReader(10)

End While

MyConnection.Close()

Dim fieldNames() As String = {“CUST_NAME”, “CONTACT_NAME”, “DEPT”, “Add1”, “CITY”, “STATE”, “COUNTRY”, “ZIPCODE”, “PHONE”, “TELEFAX”, “PRETEXT”, “SCH_ADD”, “TERMS”, “YOUR_NAME”}

Dim fieldValues() As Object = {CUST_NAME, CONTACT_NAME, DEPT, Add1, CITY, STATE, COUNTRY, ZIPCODE, PHONE, TELEFAX, PRETEXT.Text, SCH_ADD.Text, TERMS.Text, YOUR_NAME.Text}

doc.MailMerge.Execute(fieldNames, fieldValues)

doc.Save(“myDoc1.doc”, SaveFormat.FormatDocument, Aspose.Word.SaveType.OpenInBrowser, Response)

Please advise

rgds
Pavan


#2

Here’s the Template also…

Thnx in advance!
Pavan


#3

Hi,

Thank you for considering Aspose.

You actually haven’t removed the Terms merge field, it is still in your template but for some reason is not visible in field results mode. Press Alt-F9 to switch to toggle field codes and you will see it.


#4

Thanx…That helped