Datatable to XML CSV TAB HTML Json

I have a common functions class (cfc) project i tend to fill with all functions i believe can be applied to anything and will likely be reused.
I was making some adjustments to a few handy functions and I thought it might be useful to publish the following functions which will help convert datatables to various output formats.

Visual Studio references the following libraries within my cfc project, im not entirely sure which ones are required for these functions so i will list them all.
System
System.Core
System.Data
System.DirectoryServices
System.Drawing
System.Runtime.Serialization
System.ServiceModel.Web
System.Web
System.Web.Extensions
System.Xml

We have 6 functions here
1. ConvertDtToXML
2. ConvertDtToTDF
3. ConvertDtToCSV
4. ConvertDtToJSON
5. ConvertDtToHTML
6. RenderControl

Lets talk about each one briefly.
1. ConvertDtToXML
This function is making use of .NETs Dataset object built in method GetXml, the one simple rule here is that the table must be named in order for the xml to be generated. So we simply declare a dataset, check for a table name, if none then give a standard name, add the table to the dataset and output using GetXml.

2. ConvertDtToTDF
3 things are going on here, the first for loop we get the column headings. Second we begin a for loop on all of the rows, and third we for loop against each column getting the data this time. Each loop builds up the TAB delimited string we end up with.

3. ConvertDtToCSV
A very similar approach to the tab delimited has been taken here with the CSV, its the text used to build the sting that differs.

4. ConvertDtToJSON
We make use of .NETs Json serializer to convert our datatable to a json string

5. ConvertDtToHTML and 6. RenderControl
This final converter function ConvertDtToHTML needs to use last function RenderControl.
Load the datatable into a gridview, bind it, then extract the rendered HTML from it.

Vista Boot – Element not Found

I recently had an enquiry from a user, they wanted to reclaim a partition on their machine that was allocated to emergency recovery. Seeing as the OS was different to that of the recovery I agreed.
My mistake was not to reconfigure the active primary partition. This caused the error msg Cannot find operating system.
So using the vista CD i booted in to restore mode and attempted to reconfigure the boot record, only to be presente with the message “element not found”. A quick google search yielded the solution. thanks goes to tturrisi for his accurate step by step recovery.

Excellent solution originally found here

Repair Vista Boot Loader
——————————————————————————–
If dual booting Windows & Linux, and also use GRUB, if you remove the Linux partition(s) you probably can no longer boot Windows. While this is very easy to fix if the Windows operating system is XP or earlier, it is a bit more complicated (but still easy to do) in Windows Vista.

More often than not, when removing Linux partitions in a dual boot Vista-Linux environment, or when using GPARTED to resize partitions, Vista can no longer boot.

Windows Vista uses a different boot loader than earlier versions of Windows. Fortunately the Vista bootable DVD contains a utility for repairing the MBR and boot sections of the hard drive. To repair the Vista bootloader: http://support.microsoft.com/kb/927392

However, the utility mail fail on any action and give an error message of “Element not Found”. This is because resizing the Vista partition(s) or Linux partition(s) changes the disk’s file allocation table and the Vista partition may get marked as “inactive”. The same holds true when removing or resizing Linux partitions. A boot partition MUST be marked as “active” to be bootable.

The remedy for “Element not Found” is this:

1.Put the Windows Vista installation disc in the disc drive, and then start the computer.
2.Press a key when you are prompted.
3.Select a language, a time, a currency, a keyboard or an input method, and then click Next.
4.Click Repair your computer.
5.Click the operating system that you want to repair, and then click Next. (if no Vista operating system is listed, click Next anyway)
6.In the System Recovery Options dialog box, click Command Prompt.

Next:

At the command prompt, type diskpart.
This will get you to the DiskPart prompt, which allows you to use a variety of hard disk partitioning and formatting tools similar to FDISK in older versions of Windows.

At the DiskPart prompt, type select disk # where the # sign is the number of the hard disk drive with Vista installed on it. If your Vista drive is the only hard drive in your computer, it is Disk 0.

Select the partition by typing select partition # where the # sign is the partition that has Vista installed on it.

Type active and press ENTER. The Vista partition is now active. Finally, type ‘exit’ to close DiskPart. Reboot the computer using the Vista dvd and follow steps 1-6 above. You can now repair the Vista boot:

Fix the Master Boot Record: (commands)

bootrec /fixmbr
bootrec /rebuildbcd
bootrec /fixboot