sql - how to create XML file from database in vb.net -


how create xml file database using vb.net tried got root elements created , not data's database , code is:

<% @import namespace="system" %> <% @import namespace="system.data" %> <% @import namespace="system.xml" %> <% @import namespace="system.data.sqlclient" %>  <script runat="server"> sub page_load  dim connectionstring string dim connection sqlconnection dim adapter sqldataadapter dim ds  new dataset dim sql string  connectionstring =// connection string/// connection = new sqlconnection(connectionstring)    sql = "select * jb_jobs city='los angeles' " connection.open() adapter = new sqldataadapter(sql, connection) adapter.fill(ds) connection.close() if io.file.exists("product.xml") = false dim settings new xmlwritersettings() settings.indent = true dim xmlwrt xmlwriter = xmlwriter.create("c:/xmlfiles/product.xml", settings) xmlwrt.writestartdocument() xmlwrt.writecomment("xml database.") xmlwrt.writestartelement("source") xmlwrt.writestartelement("jobs")    xmlwrt.writeendelement() xmlwrt.writeenddocument() xmlwrt.close() end if end sub </script> 

and got output xml file created root elements described above , not data's database.

how data's database , form xml file?

try using writexml method, this:

private sub writexmltofile(thisdataset dataset)  if thisdataset nothing       return   end if    ' create file name write to.   dim filename string = "xmldoc.xml"    ' create filestream write with.   dim stream new system.io.filestream _     (filename, system.io.filemode.create)   ' write file writexml method.  thisdataset.writexml(stream) end sub 

you can find out more datatable.writexml , dataset.writexml on msdn.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -