Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 8th, 2007, 05:34 AM
Authorized User
Join Date: Feb 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to output dataset to .txt file not to .xml?

How can i write the dataset result to text file .txt not to .xml??????????????

or what should i do to save the output results of the two dataAdapters to .txt file or any other file format that could be used as a receipt for new orders

SqlConnection con = new SqlConnection();

con.ConnectionString = "Server=YOUR-0699539F8F\\SQLExpress;Initial Catalog=TheBeerHouse;Integrated Security=true";

SqlDataAdapter da2 = new SqlDataAdapter((" select OrderID, AddedBy, AddedDate, ShippingMethod, ShippedDate, Subtotal, Shipping, ShippingFirstName, ShippingLastName, ShippingStreet, ShippingPostalCode, ShippingCity, ShippingState, ShippingCountry, CustomerEmail, CustomerPhone, CustomerFax from tbh_Orders where OrderID = (select Max(OrderID) from tbh_Orders)"), con);

SqlDataAdapter da = new SqlDataAdapter((" Select OrderID, OrderItemID, Title, TitleA, SKU, UnitPrice, Quantity from tbh_OrderItems where OrderID = (select Max(OrderID) from tbh_OrderItems)"), con);

DataSet myds = new DataSet();

da2.Fill(myds, "Orders");

da.Fill(myds, "OrderItems");

DataRelation rel = myds.Relations.Add("MyRelation", myds.Tables[0].Columns["OrderID"], myds.Tables[1].Columns["OrderID"]);

rel.Nested = true;

myds.WriteXml("c:\\NestedXml3.xml", XmlWriteMode.IgnoreSchema);

Reply With Quote
  #2 (permalink)  
Old March 8th, 2007, 11:34 AM
Friend of Wrox
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts

That would depend on the format of the txt file.
If you just want to output the XML to a file with the extension of txt rather than xml, that is easy enough.

In other words, what do you want to output to the text file? You can easily write your own class that outputs data from the dataset (or from the xml representation of a dataset for that matter) to a stream, a string, or a file.

Woody Z
How to use a forum to help solve problems
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with PHP file reading XML file for output rydog65 Beginning PHP 0 March 26th, 2008 05:13 PM
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
How to output dataset to .txt file not to .xml? nesrine ASP.NET 2.0 Professional 0 March 8th, 2007 05:36 AM
XML Output file Neal Crystal Reports 0 October 24th, 2006 07:02 AM
Disassembler (output on .txt file) gettipu J2EE 0 February 20th, 2005 03:19 PM

All times are GMT -4. The time now is 10:43 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.