<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>RedSouljaz Blog &#187; Data Table to CSV</title>
	<atom:link href="http://redsouljaz.com/tag/data-table-to-csv/feed/" rel="self" type="application/rss+xml" />
	<link>http://redsouljaz.com</link>
	<description>My Personal Blog&#039;s</description>
	<lastBuildDate>Mon, 25 Apr 2011 09:17:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>VB.NET Set Data Table to CSV File</title>
		<link>http://redsouljaz.com/2010/06/03/vb-net-set-data-table-to-csv-file/</link>
		<comments>http://redsouljaz.com/2010/06/03/vb-net-set-data-table-to-csv-file/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 09:22:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Data Table to CSV]]></category>
		<category><![CDATA[datatable 2 csv]]></category>
		<category><![CDATA[DataTable to CSV]]></category>
		<category><![CDATA[Set Data Table to CSV File]]></category>
		<category><![CDATA[VB.NET Set Data Table to CSV File]]></category>

		<guid isPermaLink="false">http://redsouljaz.com/?p=323</guid>
		<description><![CDATA[This function show how to Convert DataTable to CSV File 

    Sub SetDataTable_To_CSV(ByVal dtable As DataTable, ByVal path_filename As String, ByVal sep_char As String)
        Dim writer As System.IO.StreamWriter
        Try
          [...]]]></description>
			<content:encoded><![CDATA[<p>This function show how to Convert DataTable to CSV File </p>
<pre class="brush: vb;">
    Sub SetDataTable_To_CSV(ByVal dtable As DataTable, ByVal path_filename As String, ByVal sep_char As String)
        Dim writer As System.IO.StreamWriter
        Try
            writer = New System.IO.StreamWriter(path_filename)

            Dim _sep As String = &quot;&quot;
            Dim builder As New System.Text.StringBuilder
            For Each col As DataColumn In dtable.Columns
                builder.Append(_sep).Append(col.ColumnName)
                _sep = sep_char
            Next
            writer.WriteLine(builder.ToString())

            For Each row As DataRow In dtable.Rows
                _sep = &quot;&quot;
                builder = New System.Text.StringBuilder

                For Each col As DataColumn In dtable.Columns
                    builder.Append(_sep).Append(row(col.ColumnName))
                    _sep = sep_char
                Next
                writer.WriteLine(builder.ToString())
            Next
        Catch ex As Exception

        Finally
            If Not writer Is Nothing Then writer.Close()
        End Try
    End Sub
</pre>
<p>This is how you use it</p>
<pre class="brush: vb;">
Dim dt As New DataTable
SetDataTable_To_CSV(dt, &quot;C:\test.csv&quot;, &quot;,&quot;)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://redsouljaz.com/2010/06/03/vb-net-set-data-table-to-csv-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

