All posts by ronald

Using WordWriter to merge Word Documents

Several of our consulting projects have had a similar need: programatically merge multiple Word documents into a single Word file. Using SoftArtisans’ WordWriter, this task is fairly easy. In this article, I’ll show you how. If you’re not a current WordWriter user, you can download a free evaluation and follow along!

When you use WordWriter to merge documents, the page setup of the destination document you are merging into is used for all pages. (This follows the same behavior as Word.) If you create a new document to merge into, you’re resulting document will have default formatting.

If you want to preserve the formatting of each document that you are merging, insert a section break in your final output file before merging each document. You will then need to copy the formatting information from each document to the section you just created. Some types of document formatting that you may want to preserve include: margins; paper size or orientation; page borders; vertical alignment; and number of columns. (Text formatting, such as font, font size, text color are preserved, so you don’t need to manually set these.) Continue reading Using WordWriter to merge Word Documents

Reducing the Size of SQL Server Log Files

I just ran into a problem where we were not able to create new tables in the database.  The CREATE TABLE command would simply hang.  After examining the log files, we saw the following error:

“Autogrow of file ‘<database_name>_log’ in database ‘<database_name>’ was cancelled by user or timed out after … ”

I examined the log files and found that the log file for the database had grown to over 50Gb.

My first attempt to truncate the log file was to use the “Shrink file” option from within Microsoft SQL Server Management Studio.  To get there, right-click on the database name, select “Tasks” -> “Shrink” -> “Files”.  In the dialog box that appears, change the file type from “Data” to “Log”.  I tried several time to shrink the log file this way.  No luck.  I was not able to reduce the size of the log size to less than its allocated 50Gb.

The solution that my co-worker and I found was to use some SQL statements to reduce the log file size.  The SQL we used was as follows: Continue reading Reducing the Size of SQL Server Log Files

Reducing the Length of XML Data Returned from a Web Service

I’m working on a project for a large consulting customer.  The application we’re developing has a SOA that uses WCF services to return data.  A requirement is that the data be communicated using XML for maximum interoperability between potential heterogenous (Microsoft and non-Microsoft) environments.

The problem I’ve run into is that some of the data sets can be quite large.  We’re using the built-in functionality of the ASP.NET DatSet object to serialize the data and table schema information to XML.  This is very fast and convenient to code, but the generated XML is very verbose and adds a lot of overhead.  This resulted in errors in clients of the web service with the message “The maximum message size quota for incoming messages (n) has been exceeded“.  I increased the MaxReceivedMessageSize property on the binding in the web.config file to 50000000 (yes, that’s 50Mb), but I still ran into the same error.  I really didn’t want to keep increasing the max message size and be sending 50Mb, or even more, of XML across the wire.  Continue reading Reducing the Length of XML Data Returned from a Web Service