I've been using your word component to merge data to a document for quite some time. I'me busy re-writing my merge wrapper to use the IDataReader but I seem to be missing some data when the merge is done?? I'm expecting 20,000 pages but only get 19,922. What would cause pages not to be merged? I've checked that fields are not null, etc, but I still can't see why... Am I missing something silly?
My test code:
[Test]
public void Merge20KRecordsIn60s()
{
DateTime mergeStartTime;
// prepare merge doc
Document doc = new Document( @"c:\template.doc" );
// get data from db using data readers
using ( SqlConnection con = new SqlConnection( @"server=x;uid=x;pwd=x;database=x" ) )
{
string sql = @"select top 20000 * from dbo.table (nolock) order by column desc";
using ( SqlCommand cmd = new SqlCommand( sql, con ) )
{
cmd.CommandTimeout = 60;
cmd.Connection.Open();
SqlDataReader dr = cmd.ExecuteReader( CommandBehavior.CloseConnection );
mergeStartTime = DateTime.Now;
doc.MailMerge.Execute( dr );
doc.Save( @"c:\results.doc", SaveFormat.FormatDocument );
dr.Close();
}
}
DateTime mergeEndTime = DateTime.Now;
Assert.IsTrue( mergeEndTime < mergeStartTime.AddSeconds( 60 ) );
}
The document template just contains a few of the column names from table.