Mail Merge to Labels using asp.net 2010 with vb

I am a test Evaluation copy and I am trying to get a mail merge to work for labels. Here is the code, stored procedure and template. It never return any data in the template. The data is coming back from the stored procedure .



Private Sub GetData()
Dim myAdapter As SqlDataAdapter
Dim result As New DataSet
Dim myConnection As SqlConnection = New SqlConnection(WebConfigurationManager.ConnectionStrings(“testCenter”).ConnectionString)
Dim stlabel As New DataTable


Try
Dim sqlCommand_Label As SqlCommand
sqlCommand_Label = New SqlCommand(“Select_CondPolicyIndex_Address_Label”, myConnection)
sqlCommand_Label.CommandTimeout = 200
sqlCommand_Label.CommandType = CommandType.StoredProcedure
myConnection.Open()
myAdapter = New SqlDataAdapter(sqlCommand_Label)
myAdapter.Fill(result)
If (result.Tables.Count > 0) Then
stlabel = result.Tables(0)
stlabel.TableName = “Labels”
End If


Dim dataDir As String = “C:\LabTest”
Dim doc As New Document(dataDir & Convert.ToString(“LabelTest.docx”))


doc.MailMerge.ExecuteWithRegions(stlabel)

Dim dataOut As String = dataDir & Convert.ToString(“LabelTestout.docx”)
doc.Save(dataOut)





Catch ex As Exception
Throw (ex)

Finally
If myConnection.State = ConnectionState.Open Then
myConnection.Close()

End If
End Try





Catch ex As Exception
Throw (ex)

Finally
If myConnection.State = ConnectionState.Open Then
myConnection.Close()

End If
End Try
End Sub


stored Procedures
ALTER PROCEDURE [dbo].[Select_CondPolicyIndex_Address_Label]
AS
SELECT top 100 CurrentName as CurrentName
, Address as Address
, City as City
, State as State
, ZipCode as ZipCpde
FROM Address_GL

Hi Renee,


Thanks for your inquiry. The TableEnd:Labels field is missing in your document. It is TableStart:Labels. Press Alt + F9 to see the field codes. Please use the attached modified document to fix this issue.

Please let us know if you have any more queries.

Thanks, but now when I am now getting. Any ideas.

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Source Error:

Hi Renee,


Thanks for your inquiry.

Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing. We will investigate the issue on our side and provide you more information.