I have a Silverlight application that reads its content from an XML file.
The user can enter data and It’ll be stored in SQL database.
How can I read the data from SQL database and store it into an XML file?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One easy way (presuming you are using SQL Server) is to append
FOR XML AUTOon the end of your query that retrieves the data. This then returns the result set as an XML file. For example, taking the Northwind database as an example, you could use this query:This would generate the following XML:
See Retrieving Data as XML from SQL Server for more information.
To retrieve your data from SQL Server you will need to use ADO.NET. This is too big a topic to go into detail here, so I suggest reading a tutorial. However, the basic premise is you query the database and return your data as XML and then store this in a string. Once in a string you can write this to a file.