|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Query results to fileVB.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 Rick,
The shortest answer possible. YourDataSet.WriteXML("your path" , 4 different options) Cor Show quoteHide quote "Rick" <R***@LakeValleySeed.com> schreef in bericht news:eg1ADwF9GHA.1012@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 > 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 Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:OcwovVG9GHA.4568@TK2MSFTNGP02.phx.gbl... > Rick, > > The shortest answer possible. > > YourDataSet.WriteXML("your path" , 4 different options) > > Cor > > "Rick" <R***@LakeValleySeed.com> schreef in bericht > news:eg1ADwF9GHA.1012@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 >> > > 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" <R***@LakeValleySeed.com> wrote in message Thats not quite what I want.news:uAX657R9GHA.4620@TK2MSFTNGP02.phx.gbl... Thanks Cor, 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 Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:OcwovVG9GHA.4568@TK2MSFTNGP02.phx.gbl... > Rick, > > The shortest answer possible. > > YourDataSet.WriteXML("your path" , 4 different options) > > Cor > > "Rick" <R***@LakeValleySeed.com> schreef in bericht > news:eg1ADwF9GHA.1012@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 >> > > 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" <mali***@verizon.net> wrote in message news:7fw_g.1165$Wp3.428@trndny05...Show quoteHide quote > 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" <R***@LakeValleySeed.com> wrote in message > news:uAX657R9GHA.4620@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]" <notmyfirstn***@planet.nl> wrote in message > news:OcwovVG9GHA.4568@TK2MSFTNGP02.phx.gbl... >> Rick, >> >> The shortest answer possible. >> >> YourDataSet.WriteXML("your path" , 4 different options) >> >> Cor >> >> "Rick" <R***@LakeValleySeed.com> schreef in bericht >> news:eg1ADwF9GHA.1012@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 >>> >> >> > > > Rick,
Why than not write it simple with the stramwriter as textfile. sr.Write. Cor Show quoteHide quote "Rick" <R***@LakeValleySeed.com> schreef in bericht news:OIHjL%23d9GHA.3396@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" <mali***@verizon.net> wrote 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" <R***@LakeValleySeed.com> wrote in message >> news:uAX657R9GHA.4620@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]" <notmyfirstn***@planet.nl> wrote in message >> news:OcwovVG9GHA.4568@TK2MSFTNGP02.phx.gbl... >>> Rick, >>> >>> The shortest answer possible. >>> >>> YourDataSet.WriteXML("your path" , 4 different options) >>> >>> Cor >>> >>> "Rick" <R***@LakeValleySeed.com> schreef in bericht >>> news:eg1ADwF9GHA.1012@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 >>>> >>> >>> >> >> >> > > 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_SALESDOCTableAdapter 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 Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:uBPI7gl9GHA.3960@TK2MSFTNGP05.phx.gbl... > Rick, > > Why than not write it simple with the stramwriter as textfile. > > sr.Write. > > Cor > 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 Show quoteHide quote "Rick" <R***@LakeValleySeed.com> schreef in bericht news:utfOJRp9GHA.3760@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_SALESDOCTableAdapter > > 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]" <notmyfirstn***@planet.nl> wrote in message > news:uBPI7gl9GHA.3960@TK2MSFTNGP05.phx.gbl... >> Rick, >> >> Why than not write it simple with the stramwriter as textfile. >> >> sr.Write. >> >> Cor >> > > 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 Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:%23y4TZMs9GHA.4376@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" <R***@LakeValleySeed.com> schreef in bericht > news:utfOJRp9GHA.3760@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_SALESDOCTableAdapter >> >> 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]" <notmyfirstn***@planet.nl> wrote in message >> news:uBPI7gl9GHA.3960@TK2MSFTNGP05.phx.gbl... >>> Rick, >>> >>> Why than not write it simple with the stramwriter as textfile. >>> >>> sr.Write. >>> >>> Cor >>> >> >> > > No just my other answer, because your XML set is a string you just can write
it completely in one time. Cor Show quoteHide quote "Rick" <R***@LakeValleySeed.com> schreef in bericht news:eKJIOUu9GHA.3620@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]" <notmyfirstn***@planet.nl> wrote in message > news:%23y4TZMs9GHA.4376@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" <R***@LakeValleySeed.com> schreef in bericht >> news:utfOJRp9GHA.3760@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_SALESDOCTableAdapter >>> >>> 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]" <notmyfirstn***@planet.nl> wrote in message >>> news:uBPI7gl9GHA.3960@TK2MSFTNGP05.phx.gbl... >>>> Rick, >>>> >>>> Why than not write it simple with the stramwriter as textfile. >>>> >>>> sr.Write. >>>> >>>> Cor >>>> >>> >>> >> >> > >
frmViewAll.DefInstance.Hide()
SQL Stored procedure Streamreader problem Datasets and Adapter Updates Deleteing all files from target folder as a presetup task how to translate from c# this instruction Building my own "SMTP" mail - control ? Custom Control hard code data bind best code profiler to get? |
|||||||||||||||||||||||