Hi, I'm new to ASP.NET and working in databases. I'm wishing to query a database and output the results of the query in XML, where each row returned by the database is another element in the XML doc.
So, let's say the database has 30 rows and each has a unique ID, a person's name, their address, and a latitude and longitude for each.
In ASP with VBScript you might execute a SQL query where the results are stored in a recordset object, and then you'd execute a loop that cycles through each record in the recordset spitting out the text and moving onto the next record. The loop would terminate when the recordset would reach end of file (EOF).
How would one achieve the same results in ASP.NET, written in C#?
Side question: How hard is it to process and properly encode the values from the DB so they are valid XML, as well, in the event odd characters are in it?
I'm attaching sample database contents and a sample output.
--- Sample database ---
1,"John","Smith","222 W Main St., Springfield, USA",41.25454,-88.548798
2,"Mary","Jones","123 N Western Av., Springfield, USA",41.27876,-88.5874312
3,"Donatella","Kochanowski","321 S East Av., Springfield, USA",41.2678487,-87.978974
--- Sample Output ---
<?xml version="1.0" encoding="utf-8" ?>
<customer firstname="John" lastname="Smith" address="222 W. Main St., Springfield, USA" latitude="41.25454" longitude="-88.548798" />