|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB6 - Saving query results as XMLHow can I issue a SQL query from my VB program and get the results back as XML? Normally I do: strSQL = "SELECT * FROM MyTable" RS.Open strSQL, conn, adOpenKeyset, adLockOptimistic to return an ADODB recordset (RS). However if I want the results as XML I could use "SELECT * FROM MyTable FOR XML AUTO" but then in what structure do the results get returned - a string? What if the results are too big for a string variable? I've tried setting up an ADODB.Command (Cmd) and issuing Cmd.Execute but how do I assign the results to a variable in the program? Has anyone got any ideas? Thanks Bod Bod <B**@discussions.microsoft.com>'s wild thoughts were
released on Mon, 19 Feb 2007 06:33:13 -0800 bearing the following fruit: Show quoteHide quote >Hi, I have no idea about returning XML, but I do know an ADO> >How can I issue a SQL query from my VB program and get the results back as >XML? > >Normally I do: >strSQL = "SELECT * FROM MyTable" >RS.Open strSQL, conn, adOpenKeyset, adLockOptimistic >to return an ADODB recordset (RS). > >However if I want the results as XML I could use >"SELECT * FROM MyTable FOR XML AUTO" >but then in what structure do the results get returned - a string? What if >the results are too big for a string variable? >I've tried setting up an ADODB.Command (Cmd) and issuing Cmd.Execute but how >do I assign the results to a variable in the program? > recordset allows you to save the results as an XML file. Jan Hyde (VB MVP) -- Meditation is not what you think.
Show quote
Hide quote
"Jan Hyde" wrote: Bod> Bod <B**@discussions.microsoft.com>'s wild thoughts were > released on Mon, 19 Feb 2007 06:33:13 -0800 bearing the > following fruit: > > >Hi, > > > >How can I issue a SQL query from my VB program and get the results back as > >XML? > > > >Normally I do: > >strSQL = "SELECT * FROM MyTable" > >RS.Open strSQL, conn, adOpenKeyset, adLockOptimistic > >to return an ADODB recordset (RS). > > > >However if I want the results as XML I could use > >"SELECT * FROM MyTable FOR XML AUTO" > >but then in what structure do the results get returned - a string? What if > >the results are too big for a string variable? > >I've tried setting up an ADODB.Command (Cmd) and issuing Cmd.Execute but how > >do I assign the results to a variable in the program? > > > > I have no idea about returning XML, but I do know an ADO > recordset allows you to save the results as an XML file. > > > > > Jan Hyde (VB MVP) > > -- > Meditation is not what you think. > > Really? So if I have a variable RS returned as an ADO recordset I can save that as XML? What method performs that trick? Bod <B**@discussions.microsoft.com>'s wild thoughts were
released on Mon, 19 Feb 2007 09:34:05 -0800 bearing the following fruit: Show quoteHide quote > Sure, look at the save method. Also you can load the XML> >"Jan Hyde" wrote: > >> Bod <B**@discussions.microsoft.com>'s wild thoughts were >> released on Mon, 19 Feb 2007 06:33:13 -0800 bearing the >> following fruit: >> >> >Hi, >> > >> >How can I issue a SQL query from my VB program and get the results back as >> >XML? >> > >> >Normally I do: >> >strSQL = "SELECT * FROM MyTable" >> >RS.Open strSQL, conn, adOpenKeyset, adLockOptimistic >> >to return an ADODB recordset (RS). >> > >> >However if I want the results as XML I could use >> >"SELECT * FROM MyTable FOR XML AUTO" >> >but then in what structure do the results get returned - a string? What if >> >the results are too big for a string variable? >> >I've tried setting up an ADODB.Command (Cmd) and issuing Cmd.Execute but how >> >do I assign the results to a variable in the program? >> > >> >> I have no idea about returning XML, but I do know an ADO >> recordset allows you to save the results as an XML file. >> >> >> >> >> Jan Hyde (VB MVP) >> >> -- >> Meditation is not what you think. >> >> Really? So if I have a variable RS returned as an ADO recordset I can save that as XML? What method performs that trick? > >Bod back into a ADO recordset. Jan Hyde (VB MVP) -- Unaccustomed as I am to puppies squeaking, I would like to display a few birds. (Keith Jackson) Thanks very much to you both. I hadn't realised there was an XML option on
Save. It seems to automatically dump out the schema as well as the data, but that isn't a problem. Bod Show quoteHide quote "Jan Hyde" wrote: > Bod <B**@discussions.microsoft.com>'s wild thoughts were > released on Mon, 19 Feb 2007 09:34:05 -0800 bearing the > following fruit: > > > > > > >"Jan Hyde" wrote: > > > >> Bod <B**@discussions.microsoft.com>'s wild thoughts were > >> released on Mon, 19 Feb 2007 06:33:13 -0800 bearing the > >> following fruit: > >> > >> >Hi, > >> > > >> >How can I issue a SQL query from my VB program and get the results back as > >> >XML? > >> > > >> >Normally I do: > >> >strSQL = "SELECT * FROM MyTable" > >> >RS.Open strSQL, conn, adOpenKeyset, adLockOptimistic > >> >to return an ADODB recordset (RS). > >> > > >> >However if I want the results as XML I could use > >> >"SELECT * FROM MyTable FOR XML AUTO" > >> >but then in what structure do the results get returned - a string? What if > >> >the results are too big for a string variable? > >> >I've tried setting up an ADODB.Command (Cmd) and issuing Cmd.Execute but how > >> >do I assign the results to a variable in the program? > >> > > >> > >> I have no idea about returning XML, but I do know an ADO > >> recordset allows you to save the results as an XML file. > >> > >> > >> > >> > >> Jan Hyde (VB MVP) > >> > >> -- > >> Meditation is not what you think. > >> > >> Really? So if I have a variable RS returned as an ADO recordset I can save that as XML? What method performs that trick? > > > >Bod > > Sure, look at the save method. Also you can load the XML > back into a ADO recordset. > > > > Jan Hyde (VB MVP) > > -- > Unaccustomed as I am to puppies squeaking, I would like to display a few birds. > > (Keith Jackson) > > |
|||||||||||||||||||||||