title: Make a CSV from a MySql table in ASP Classic
body: <p>It has been asked to me to make a sort of "exporting" feature on a site in ASP Classic.</p>
  
  <p>I thought it could be really simple to make, but I got some problems. I get the right numbers of row in the file, but I get always the same recordset row, something like the recordset isn't updating the values during the foreach loop.</p>
  
  <p>Here my code:</p>
  
  <pre><code>dim fs,f
  set fs = Server.CreateObject("Scripting.FileSystemObject")
  set f = fs.OpenTextFile(Server.MapPath("thebackupfile.csv"), 8, true)
  
  set RS = conn.execute("SELECT * FROM sometable")
  
  For each fField in RS.Fields 
      row = row &amp; " " &amp; fField.Name &amp; ";"     
  Next
  
  row = left (row, len(row)-1)
  
  f.WriteLine(row)
  
  do while not RS.EOF
      For each fField in RS.Fields 
          csv = csv &amp;" "&amp; RS(fField.Name) &amp; ";"     
      Next
      csv = left (csv, len(csv)-1)
  
      f.WriteLine(csv)
      RS.movenext
  loop
  
  f.Close
  set f = Nothing
  set fs = Nothing
  </code></pre>
  
  <p>I can't figure out why I get <code>n</code> times the first row with <code>n</code> equals of the number of rows in the recordset.</p>
  
  <p>Any advice? Am I taking the wrong way to do that?</p>