VB.Net --> DataSet to textfile!

Posted on 2006-10-19
Last Modified: 2008-02-01
I have a dataset that I need to write to a text file out on my server.

The text file will not exist and will need to have the current datetime timestamp in the name.  So, essentially,  I pull data from sql and create a series of datasets.  I need to output the datasets to text files that look like the following.


Any and all information is so greatly appreciated...

Question by:ucic
  • 3
  • 2
LVL 17

Expert Comment

ID: 17767790
You can output the a dataset's contents in XML format like this:

Dim strm As New IO.StreamWriter("C:\dataset1_" & Now.ToString("MM-dd-yyyy_HHmmtt") & ".txt", False, System.Text.Encoding.Unicode)

Author Comment

ID: 17767927
Im already doing this in xml and it is not a feasible solution...

The project requires that the files get output directly to pipe delimited text files...

LVL 17

Accepted Solution

ZeonFlash earned 500 total points
ID: 17768031
In that case:

Dim strRow As String
Dim i As Integer
Dim strm As New IO.StreamWriter("C:\dataset1_" & Now.ToString("MM-dd-yyyy_HHmmtt") & ".txt", False, System.Text.Encoding.Unicode)

For Each dt As DataTable In ds.Tables
      For Each dr As DataRow In dt.Rows
            strRow = Nothing
            For Each col As DataColumn In dt.Columns
                  strRow &= dr(col) & "|"
            strRow = strRow.Remove(strRow.Length - 1, 1)


Author Comment

ID: 17768082
Seems to create the text file, seems to be create a pipe & tab delimeter...
Any ideas?

Author Comment

ID: 17768377
Got it figured out...I had a char datatype...All fixed...You Rock!

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now