473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Writing From A dataset to a comma delimited text file

Does any one know how to write the data from a dataset table to a text file? I have found a clumsy way to do it using WriteXml, XmlReader, XmlNodeReader, etc, but this seems awful clumsy. Is there a better way to do this?

--
JOHN TYCE
Nov 16 '05 #1
4 9990
John,

There is no way to do it out of the box. You will have to write the
file yourself (cycling through all columns for each row).

You ^might^ be able to do it using a text provider (I think that there
was one for OLEDB), but I am not sure that would work. Or perhaps, an ODBC
provider.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Tyce" <jt***@chevrontexaco.com> wrote in message
news:eq*************@TK2MSFTNGP12.phx.gbl...
Does any one know how to write the data from a dataset table to a text file?
I have found a clumsy way to do it using WriteXml, XmlReader, XmlNodeReader,
etc, but this seems awful clumsy. Is there a better way to do this?

--
JOHN TYCE
Nov 16 '05 #2
John,

Check this link out:
http://support.microsoft.com/default...b;EN-US;306023

--
Patrick Altman
[Remove "JUST_SAY_NO_TO_SPAM" to send me email.]
"John Tyce" <jt***@chevrontexaco.com> wrote in message
news:eq*************@TK2MSFTNGP12.phx.gbl...
Does any one know how to write the data from a dataset table to a text file?
I have found a clumsy way to do it using WriteXml, XmlReader, XmlNodeReader,
etc, but this seems awful clumsy. Is there a better way to do this?

--
JOHN TYCE
Nov 16 '05 #3
Thanks Patrick. That may be very helpful.

--
JOHN TYCE
"Patrick Altman" <paltman@gmailJUST_SAY_NO_TO_SPAM.com> wrote in message
news:el**************@TK2MSFTNGP09.phx.gbl...
John,

Check this link out:
http://support.microsoft.com/default...b;EN-US;306023

--
Patrick Altman
[Remove "JUST_SAY_NO_TO_SPAM" to send me email.]
"John Tyce" <jt***@chevrontexaco.com> wrote in message
news:eq*************@TK2MSFTNGP12.phx.gbl...
Does any one know how to write the data from a dataset table to a text file? I have found a clumsy way to do it using WriteXml, XmlReader, XmlNodeReader, etc, but this seems awful clumsy. Is there a better way to do this?

--
JOHN TYCE

Nov 16 '05 #4
Hi John,

Here is the code I'm using , it comes from a PPC app and does exactly what you want :)

StreamWriter writer = new StreamWriter( Config.DataPath + "\\" + Config.OldOrdersFile, false);
writer.WriteLine("Tablename=OldOrders");
foreach(DataRow dr in _oldOrders.Tables[0].Rows )
{
StringBuilder builder = new StringBuilder( 200); // None row is bigger than this
foreach(object o in dr.ItemArray)
{

builder.Append( o.ToString() );
builder.Append( ',' );
}
builder.Remove( builder.Length-1, 1);
writer.WriteLine( builder.ToString() );
}
writer.Close();

Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"John Tyce" <jt***@chevrontexaco.com> wrote in message news:eq*************@TK2MSFTNGP12.phx.gbl...
Does any one know how to write the data from a dataset table to a text file? I have found a clumsy way to do it using WriteXml, XmlReader, XmlNodeReader, etc, but this seems awful clumsy. Is there a better way to do this?

--
JOHN TYCE
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Deepa | last post by:
I am writing a console app in c# wherein am converting a dataset into a CSV file. It works fine. But I have some values in the dataset which have a comma within(eg. A,B,C). When I view the CSV file...
1
by: The Bear | last post by:
I have populated a dataset with a tab delimited text file. When the changes are made in the dataset, I then want to write those changes from the dataset to a tab delimited text file. How do I write...
15
by: ruca | last post by:
Hi, Can I read a .TXT File to a DataSet? How can I do that? I want to read his lines to a DropDownList. This lines are the names of employees that I export from an application that I have. I...
4
by: washoetech | last post by:
Hello, I am working on a project where I need to be able to grab the data from an Excel spreadsheet and create a new table in my database based on the columns in the spreadsheet. After the...
6
by: dast | last post by:
Hello, I’m having trouble writing the contents of a dataset to a csv file. I have made a solution that loops through the rows in the dataset, but it’s too slow. There must be a faster and...
12
by: Chris Springer | last post by:
I'd like to get some feedback on the issue of storing data out to disk and where to store it. I've never been in a production environment in programming so you'll have to bear with me... My...
3
by: David P. Donahue | last post by:
I'm re-writing an application in C# that was originally written in Delphi 7. The heart of the application is a DataSet displayed in a DataGrid. One of the main functions of the previous...
4
by: JustSomeGuy | last post by:
Hi. I have a comma delimited text file that I want to parse. I was going to use fscanf from the C library but as my app is written in C++ I thought I'd use the std io stream library... My Text...
6
by: Kbalz | last post by:
Trying to run a simple query on my dataset the SQL statement looks like this: select * from person where id in (@p) When using more than one id in the "in statement", I get...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.