Hi All,
I am looking for a way to export a sql server 2005 table to xml using VB or C#. This is done easliy with MS Access but I am having trouble finding any information for SQL SERVER 2005.
Thanks for the help,
Bones
Hi there,
You can download your database data to dataset and use dataset to saveas xml with or without schema.
e.g.
DataSet ds =newDataSet();System.Data.SqlClient.SqlDataAdapter da =new System.Data.SqlClient.SqlDataAdapter("Select * from [tablename]","YourConnectionString");da.fill(ds);
// Write to XML here
ds.WriteXml(@."c:\output.xml",XmlWriteMode.WriteSchema);
|||Perfect!
Thank you!
In VB:
Protected Sub Button1_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Button1.ClickDim dsAs New Data.DataSet()Dim daAs New System.Data.SqlClient.SqlDataAdapter("Select * from [table]","YourConnectionString") da.fill(ds) ' Write to XML here ds.WriteXml("c:\output.xml", Data.XmlWriteMode.WriteSchema)End Sub|||
Hi There,
Am i deserve a mark as "Answer" here or what ?
|||oops thought I did. Thanks again!
|||Hi There,
Thanks, im not being mean, but i think i deserve a good point here . ;).
Please feel free to raise a question. Happy to help.
No comments:
Post a Comment