Save a Recordset to an ASCII file with custom field separators

  • Thread starter Edward Grosso via .NET 247
  • Start date
E

Edward Grosso via .NET 247

Hi to all the dotnet community,
I'm actually trying to figure out how can I save a Recordset to an ASCII file with custom field separators, in a fast way, without loops. Perhaps there is some way with a streamwriter object ?
Any idea ?
Thanks in advance
 
P

Patrice

There is no "recordset" in ADO.NET. You could try to get the XML for these
date and transform using XSL.

Patrice

--

Edward Grosso via .NET 247 said:
Hi to all the dotnet community,
I'm actually trying to figure out how can I save a Recordset to an ASCII
file with custom field separators, in a fast way, without loops. Perhaps
there is some way with a streamwriter object ?
 
H

Herman Kheyfets

Apply XSLT on dataset/datatable XML, then you dont need to loop.

Thanks
Gerasha MCSD


Edward Grosso via .NET 247 said:
Hi to all the dotnet community,
I'm actually trying to figure out how can I save a Recordset to an ASCII
file with custom field separators, in a fast way, without loops. Perhaps
there is some way with a streamwriter object ?
 
D

David Browne

Edward Grosso via .NET 247 said:
Hi to all the dotnet community,
I'm actually trying to figure out how can I save a Recordset to an ASCII
file with custom field separators, in a fast way, without loops. Perhaps
there is some way with a streamwriter object ?
Any idea ?

You realize that by "without loops" you mean "without loops that you write",
whatever method you choose will invariably be implemented by looping. So
you might as well just write it yourself.

public shared sub DumpDataTable(dt asDataTable, fileName as string)

dim outFile as new System.IO.StreamWriter("out.txt")

for each col as DataColumn in dt.Columns
if not firstCol then
outFile.Write("|")
firstCol = false
end if
outFile.Write(col.ColumnName())
next
outFile.WriteLine("")

for each row as DataRow in dt.Rows
dim firstCol as boolean = true
for each col as DataColumn in dt.Columns
if not firstCol then
outFile.Write("|")
firstCol = false
end if
outFile.Write(row(col).ToString())
next
outFIle.WriteLine("")
next

outFile.Close()

end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top