Retrieving Large Amounts of Data From a Dataset and Writing to a File

I have written a small application that takes a large amount of data from a ADO.NET dataset and writes it away to a text file (comma delimited). Right now I just go through the dataset and write each row away to the text file. As you can imagine, this takes an awfully long time.

Can anyone recommend a better way of writing a huge amount of data stored in a dataset, into a text file (has to be comma delimited).

Thanks in advance.

[436 byte] By [Ravman] at [2007-12-28]
# 1

ADO.Net provides the functionallity to connect directly to textfiles:

www.connectionstrings.com

OLE DB
Delimited columns

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtFilesFolder\;Extended Properties="text;HDR=Yes;FMT=Delimited";

Fixed length columns

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtFilesFolder\;Extended Properties="text;HDR=Yes;FMT=Fixed";

"HDR=Yes;" indicates that the first row contains columnnames, not data. "HDR=No;" indicates the opposite.
Important note! The quota " in the string needs to be escaped using your language specific escape syntax, for example c#, c++: \", VB6, VBScript "", or maybe use a single quota '.

DMan1 at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
That allows you to read text files, but not write to them.
Ravman at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

Ravman,

Use the FileSystem.Print method that writes display-formatted data to sequential file. The following code is an example that uses the Print and PrintLine functions to write data to a file:

FileOpen(1, "c:\trash.txt", OpenMode.Output)' Open file for output.

Print(1, "This is a test.")' Print text to file.

PrintLine(1)' Print blank line to file.

PrintLine(1, "Zone 1", TAB(), "Zone 2")' Print in two print zones.

PrintLine(1, "Hello", "World")' Separate strings with a tab.

PrintLine(1, SPC(5), "5 leading spaces ")' Print five leading spaces.

PrintLine(1, TAB(10), "Hello")' Print word at column 10.

' Assign Boolean, Date, and Error values.

Dim aBool As Boolean

Dim aDate As DateTime

aBool = False

aDate = DateTime.Parse("February 12, 1969")

' Dates and booleans are translated using locale settings of your system.

PrintLine(1, aBool, " is a Boolean value")

PrintLine(1, aDate, " is a date")

FileClose(1)' Close file.

Read the following link to get more help:

http://msdn2.microsoft.com/en-gb/library/microsoft.visualbasic.filesystem.print.aspx

BrunoYu-MSFT at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...