Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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);

  #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

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

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