473,480 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Query results to file

VB.Net 2005

I have a Firebird DB query that returns an XML file in its rows.

I want to execute this query and write the results (rows) to a file.

I am using DataTables and TableAdapters.

How can I get from the TableAdapter.GetBy method (via a stream?) and write
the results to a file?

Any suggestions?

Rick
Oct 20 '06 #1
9 2284
Rick,

The shortest answer possible.

YourDataSet.WriteXML("your path" , 4 different options)

Cor

"Rick" <Ri**@LakeValleySeed.comschreef in bericht
news:eg**************@TK2MSFTNGP05.phx.gbl...
VB.Net 2005

I have a Firebird DB query that returns an XML file in its rows.

I want to execute this query and write the results (rows) to a file.

I am using DataTables and TableAdapters.

How can I get from the TableAdapter.GetBy method (via a stream?) and write
the results to a file?

Any suggestions?

Rick

Oct 20 '06 #2
Thanks Cor,

Thats not quite what I want.

I ALREADY have XML which is output from the stored procedure in a column.

I just want to save the column text to a file.

So I guess I need some kind of stream object from this column that contains
the text and then write that to a file.

Pseudo code: ?.Write(MyColumn.ToString, "c:\temp|MyFile.txt")

Anyone?

Rick
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
Rick,

The shortest answer possible.

YourDataSet.WriteXML("your path" , 4 different options)

Cor

"Rick" <Ri**@LakeValleySeed.comschreef in bericht
news:eg**************@TK2MSFTNGP05.phx.gbl...
>VB.Net 2005

I have a Firebird DB query that returns an XML file in its rows.

I want to execute this query and write the results (rows) to a file.

I am using DataTables and TableAdapters.

How can I get from the TableAdapter.GetBy method (via a stream?) and
write the results to a file?

Any suggestions?

Rick


Oct 21 '06 #3
Use the stream writer.

--------------------------------------
Dim Mydataset As DataSet

Dim SW As New StreamWriter(File.Open("Path", FileMode.OpenOrCreate))

'Maybe a datarow enumeration?
Dim DR As DataRow
For Each DR In Mydataset.Tables(0).Rows
SW.WriteLine("Name:" & DR(0))
Next

SW.Close()

------------------------------------------------------------

--
Thiele Enterprises - The Power Is In Your Hands Now!

--
"Rick" <Ri**@LakeValleySeed.comwrote in message
news:uA**************@TK2MSFTNGP02.phx.gbl...
Thanks Cor,

Thats not quite what I want.

I ALREADY have XML which is output from the stored procedure in a column.

I just want to save the column text to a file.

So I guess I need some kind of stream object from this column that contains
the text and then write that to a file.

Pseudo code: ?.Write(MyColumn.ToString, "c:\temp|MyFile.txt")

Anyone?

Rick
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
Rick,

The shortest answer possible.

YourDataSet.WriteXML("your path" , 4 different options)

Cor

"Rick" <Ri**@LakeValleySeed.comschreef in bericht
news:eg**************@TK2MSFTNGP05.phx.gbl...
>VB.Net 2005

I have a Firebird DB query that returns an XML file in its rows.

I want to execute this query and write the results (rows) to a file.

I am using DataTables and TableAdapters.

How can I get from the TableAdapter.GetBy method (via a stream?) and
write the results to a file?

Any suggestions?

Rick



Oct 21 '06 #4
Thanks Ryan,

I'm already doing it that way - iterating through the data rows. I just
thought there was some single step way of doing this.

Its not really a big issue with the current program but I have a lot of xml
and xsl returned by my database so I was looking for the easiest method to
do this since it is something I frequently encounter.

Rick

"Ryan S. Thiele" <ma*****@verizon.netwrote in message
news:7fw_g.1165$Wp3.428@trndny05...
Use the stream writer.

--------------------------------------
Dim Mydataset As DataSet

Dim SW As New StreamWriter(File.Open("Path", FileMode.OpenOrCreate))

'Maybe a datarow enumeration?
Dim DR As DataRow
For Each DR In Mydataset.Tables(0).Rows
SW.WriteLine("Name:" & DR(0))
Next

SW.Close()

------------------------------------------------------------

--
Thiele Enterprises - The Power Is In Your Hands Now!

--
"Rick" <Ri**@LakeValleySeed.comwrote in message
news:uA**************@TK2MSFTNGP02.phx.gbl...
Thanks Cor,

Thats not quite what I want.

I ALREADY have XML which is output from the stored procedure in a column.

I just want to save the column text to a file.

So I guess I need some kind of stream object from this column that
contains
the text and then write that to a file.

Pseudo code: ?.Write(MyColumn.ToString, "c:\temp|MyFile.txt")

Anyone?

Rick
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
>Rick,

The shortest answer possible.

YourDataSet.WriteXML("your path" , 4 different options)

Cor

"Rick" <Ri**@LakeValleySeed.comschreef in bericht
news:eg**************@TK2MSFTNGP05.phx.gbl...
>>VB.Net 2005

I have a Firebird DB query that returns an XML file in its rows.

I want to execute this query and write the results (rows) to a file.

I am using DataTables and TableAdapters.

How can I get from the TableAdapter.GetBy method (via a stream?) and
write the results to a file?

Any suggestions?

Rick




Oct 22 '06 #5
Rick,

Why than not write it simple with the stramwriter as textfile.

sr.Write.

Cor

"Rick" <Ri**@LakeValleySeed.comschreef in bericht
news:OI****************@TK2MSFTNGP04.phx.gbl...
Thanks Ryan,

I'm already doing it that way - iterating through the data rows. I just
thought there was some single step way of doing this.

Its not really a big issue with the current program but I have a lot of
xml and xsl returned by my database so I was looking for the easiest
method to do this since it is something I frequently encounter.

Rick

"Ryan S. Thiele" <ma*****@verizon.netwrote in message
news:7fw_g.1165$Wp3.428@trndny05...
>Use the stream writer.

--------------------------------------
Dim Mydataset As DataSet

Dim SW As New StreamWriter(File.Open("Path", FileMode.OpenOrCreate))

'Maybe a datarow enumeration?
Dim DR As DataRow
For Each DR In Mydataset.Tables(0).Rows
SW.WriteLine("Name:" & DR(0))
Next

SW.Close()

------------------------------------------------------------

--
Thiele Enterprises - The Power Is In Your Hands Now!

--
"Rick" <Ri**@LakeValleySeed.comwrote in message
news:uA**************@TK2MSFTNGP02.phx.gbl...
Thanks Cor,

Thats not quite what I want.

I ALREADY have XML which is output from the stored procedure in a column.

I just want to save the column text to a file.

So I guess I need some kind of stream object from this column that
contains
the text and then write that to a file.

Pseudo code: ?.Write(MyColumn.ToString, "c:\temp|MyFile.txt")

Anyone?

Rick
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
>>Rick,

The shortest answer possible.

YourDataSet.WriteXML("your path" , 4 different options)

Cor

"Rick" <Ri**@LakeValleySeed.comschreef in bericht
news:eg**************@TK2MSFTNGP05.phx.gbl...
VB.Net 2005

I have a Firebird DB query that returns an XML file in its rows.

I want to execute this query and write the results (rows) to a file.

I am using DataTables and TableAdapters.

How can I get from the TableAdapter.GetBy method (via a stream?) and
write the results to a file?

Any suggestions?

Rick




Oct 23 '06 #6
I'm new to both VB and Net, so I don't understand your comment.

Here is what I have now:
__________________________________
Dim SalesDoc As New RGardenDataSetTableAdapters.P_XML_SALESDOCTableAda pter

SalesDoc.Connection = FBCon

SalesDoc.ClearBeforeFill = True

SalesDoc.Fill(RGardenDataSet.P_XML_SALESDOC, Invoicenum,
Application.StartupPath, 5)

SalesDoc.Fill(New RGardenDataSet.P_XML_SALESDOCDataTable, Invoicenum,
Application.StartupPath, 5)

Dim sw As StreamWriter = New StreamWriter(Path.Combine(XMLPath,
Invoicenum.ToString & ".xml"))

For Each dr As DataRow In RGardenDataSet.P_XML_SALESDOC.Rows

sw.WriteLine(dr("XML"))

Next

_____________________________

So my question is: Can this be abbreviated so there is less code.

Perhaps I can use the "Fill" method to write directly to a file stream
rather than the DataTable (like SalesDoc.Fill(?SomeFileStream?, Invoicenum,
Application.StartupPath, 5))?

Perhaps there is some way to get all the rows of my dr("XML") column as a
collection and write them all at once without the iteration?

Or, is what I am doing the best method?

Rick
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uB**************@TK2MSFTNGP05.phx.gbl...
Rick,

Why than not write it simple with the stramwriter as textfile.

sr.Write.

Cor

Oct 23 '06 #7
Rick,

Have a look at my first reply

Salesdoc.WriteXML("Your path as a string")

In this case a datatable is as well written as a dataset.

Cor

"Rick" <Ri**@LakeValleySeed.comschreef in bericht
news:ut**************@TK2MSFTNGP02.phx.gbl...
I'm new to both VB and Net, so I don't understand your comment.

Here is what I have now:
__________________________________
Dim SalesDoc As New RGardenDataSetTableAdapters.P_XML_SALESDOCTableAda pter

SalesDoc.Connection = FBCon

SalesDoc.ClearBeforeFill = True

SalesDoc.Fill(RGardenDataSet.P_XML_SALESDOC, Invoicenum,
Application.StartupPath, 5)

SalesDoc.Fill(New RGardenDataSet.P_XML_SALESDOCDataTable, Invoicenum,
Application.StartupPath, 5)

Dim sw As StreamWriter = New StreamWriter(Path.Combine(XMLPath,
Invoicenum.ToString & ".xml"))

For Each dr As DataRow In RGardenDataSet.P_XML_SALESDOC.Rows

sw.WriteLine(dr("XML"))

Next

_____________________________

So my question is: Can this be abbreviated so there is less code.

Perhaps I can use the "Fill" method to write directly to a file stream
rather than the DataTable (like SalesDoc.Fill(?SomeFileStream?,
Invoicenum, Application.StartupPath, 5))?

Perhaps there is some way to get all the rows of my dr("XML") column as a
collection and write them all at once without the iteration?

Or, is what I am doing the best method?

Rick
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uB**************@TK2MSFTNGP05.phx.gbl...
>Rick,

Why than not write it simple with the stramwriter as textfile.

sr.Write.

Cor


Oct 23 '06 #8
I tried that, but it does not give results that I want.

Here is the output from my "XML" column of the SP

row 1 <?xml version="1.0?>
row 2 <salesdoc>
row 3 <items>
row 4 <item number="1234" qty="6"...>
....and so on
row x </salesdoc>

When I SalesDoc.WriteXML I got (unescaped)

<tag created by .Net>
<?xml version="1.0">
</tag created by .Net>
<tag created by .Net>
<salesdoc>
</tag created by .Net>

so my xml is wrapped inside NET created tags which is not what I want. I
think it was a mistake to mention that my sp output XML since it just
confused matters.

Forget that I am starting with XML and just consider that I want to output a
string column to a file stream. For this case is iterating through the rows
and WriteLine("text value") the best way to go?

Rick
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Rick,

Have a look at my first reply

Salesdoc.WriteXML("Your path as a string")

In this case a datatable is as well written as a dataset.

Cor

"Rick" <Ri**@LakeValleySeed.comschreef in bericht
news:ut**************@TK2MSFTNGP02.phx.gbl...
>I'm new to both VB and Net, so I don't understand your comment.

Here is what I have now:
__________________________________
Dim SalesDoc As New
RGardenDataSetTableAdapters.P_XML_SALESDOCTableAd apter

SalesDoc.Connection = FBCon

SalesDoc.ClearBeforeFill = True

SalesDoc.Fill(RGardenDataSet.P_XML_SALESDOC, Invoicenum,
Application.StartupPath, 5)

SalesDoc.Fill(New RGardenDataSet.P_XML_SALESDOCDataTable, Invoicenum,
Application.StartupPath, 5)

Dim sw As StreamWriter = New StreamWriter(Path.Combine(XMLPath,
Invoicenum.ToString & ".xml"))

For Each dr As DataRow In RGardenDataSet.P_XML_SALESDOC.Rows

sw.WriteLine(dr("XML"))

Next

_____________________________

So my question is: Can this be abbreviated so there is less code.

Perhaps I can use the "Fill" method to write directly to a file stream
rather than the DataTable (like SalesDoc.Fill(?SomeFileStream?,
Invoicenum, Application.StartupPath, 5))?

Perhaps there is some way to get all the rows of my dr("XML") column as a
collection and write them all at once without the iteration?

Or, is what I am doing the best method?

Rick
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uB**************@TK2MSFTNGP05.phx.gbl...
>>Rick,

Why than not write it simple with the stramwriter as textfile.

sr.Write.

Cor



Oct 23 '06 #9
No just my other answer, because your XML set is a string you just can write
it completely in one time.

Cor

"Rick" <Ri**@LakeValleySeed.comschreef in bericht
news:eK**************@TK2MSFTNGP04.phx.gbl...
>I tried that, but it does not give results that I want.

Here is the output from my "XML" column of the SP

row 1 <?xml version="1.0?>
row 2 <salesdoc>
row 3 <items>
row 4 <item number="1234" qty="6"...>
...and so on
row x </salesdoc>

When I SalesDoc.WriteXML I got (unescaped)

<tag created by .Net>
<?xml version="1.0">
</tag created by .Net>
<tag created by .Net>
<salesdoc>
</tag created by .Net>

so my xml is wrapped inside NET created tags which is not what I want. I
think it was a mistake to mention that my sp output XML since it just
confused matters.

Forget that I am starting with XML and just consider that I want to output
a string column to a file stream. For this case is iterating through the
rows and WriteLine("text value") the best way to go?

Rick
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Rick,

Have a look at my first reply

Salesdoc.WriteXML("Your path as a string")

In this case a datatable is as well written as a dataset.

Cor

"Rick" <Ri**@LakeValleySeed.comschreef in bericht
news:ut**************@TK2MSFTNGP02.phx.gbl...
>>I'm new to both VB and Net, so I don't understand your comment.

Here is what I have now:
__________________________________
Dim SalesDoc As New
RGardenDataSetTableAdapters.P_XML_SALESDOCTableA dapter

SalesDoc.Connection = FBCon

SalesDoc.ClearBeforeFill = True

SalesDoc.Fill(RGardenDataSet.P_XML_SALESDOC, Invoicenum,
Application.StartupPath, 5)

SalesDoc.Fill(New RGardenDataSet.P_XML_SALESDOCDataTable, Invoicenum,
Application.StartupPath, 5)

Dim sw As StreamWriter = New StreamWriter(Path.Combine(XMLPath,
Invoicenum.ToString & ".xml"))

For Each dr As DataRow In RGardenDataSet.P_XML_SALESDOC.Rows

sw.WriteLine(dr("XML"))

Next

_____________________________

So my question is: Can this be abbreviated so there is less code.

Perhaps I can use the "Fill" method to write directly to a file stream
rather than the DataTable (like SalesDoc.Fill(?SomeFileStream?,
Invoicenum, Application.StartupPath, 5))?

Perhaps there is some way to get all the rows of my dr("XML") column as
a collection and write them all at once without the iteration?

Or, is what I am doing the best method?

Rick
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uB**************@TK2MSFTNGP05.phx.gbl...
Rick,

Why than not write it simple with the stramwriter as textfile.

sr.Write.

Cor



Oct 24 '06 #10

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

Similar topics

9
3103
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
10
149089
by: Alex | last post by:
Hi, How would I go about writing the results of an SQL query to a text file? I cannot find any info in the Online help files. For example, I would like the results of: SELECT * FROM...
1
1522
by: Trillium | last post by:
I am trying to query a SQL Server database, retrieve the results as XML, and save them to a file. I was trying to use the SqlXmlCommand, SqlXmlCommandType.XPath and an xsd to query the database,...
0
4171
by: Mike Knight | last post by:
(I've also posted this problem on microsoft.public.excel.programming) I have a MS Access 2003 Database named "AS400 Fields.mdb". This database contains links to tables on an AS400. In MS...
0
1887
by: Rob | last post by:
I doubt this is the best way to do it, but what I came up with was to hide the XML in an HTML Comment then edit the file deleting the HTML stuff and keep the XML results. If anyone has a better...
7
7264
by: Bernard D | last post by:
Hi, I'm using Access 97. I can run a query that finds a number of records, I then need to access these results to build a formatted text file containing all of the results. There will be 25...
17
2704
by: NeoAlchemy | last post by:
I am starting to find more web pages that are using a query parameters after the JavaScript file. Example can be found at www.opensourcefood.com. Within the source you'll see: <script...
2
1794
by: hafner | last post by:
Hello all, I have an extremely simple query I'm running on a linked table. However, when I run it (primarily, I'm exporting to a .txt file, but the behavior persists even if I run the query), it...
1
6528
by: sxwend | last post by:
I am trying to use the following post results (http://www.thescripts.com/forum/thread189759.html) and add another requirement. I need to send the results to just the email addresses that the query...
5
3811
by: slickdock | last post by:
I need to break my query into 3 groups: First 60 records (records 1-60) Next 60 records (records 61-121) Next 60 records (records 122-182) Of course I could use top values 60 for the first...
0
7037
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
6904
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
7076
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
6873
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...
1
4767
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2990
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1294
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
174
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.