title: name a file using a record in the database using vbs
body: <p>well, i´m trying to make a visualscript which creates a file where a recordset is written in it and the name of the file is as a record of the database, to put an example, I want a query, the query is written in the file, and the name of the file is one of the rows of a table, here is my code:</p>
  
  <pre><code>Dim Filename 
  Dim Connection 
  Dim commandoSQL 
  Dim Archivo 
  Dim Nombre 
  Dim objFSO 
  Dim outputFile 
  
  Call Main
  Sub Main
      Set objFSO=CreateObject("Scripting.FileSystemObject")
      Call startConnection()  Set commandoSQL = Connection.Execute("select rest_def.obj_num, hdr_def.line_01, hdr_def.line_02, hdr_def.line_03, hdr_def.line_04, hdr_def.line_05, hdr_def.line_06, trlr_def.line_01, trlr_def.line_02, trlr_def.line_03, trlr_def.line_04, trlr_def.line_05, trlr_def.line_06, trlr_def.line_07, trlr_def.line_08, trlr_def.line_09, trlr_def.line_10, trlr_def.line_11, trlr_def.line_12 from rest_def inner join hdr_def on hdr_def.obj_num rest_def.obj_num inner join trlr_def on trlr_def.obj_num = hdr_def.obj_num where hdr_def.obj_num = 101")
      'Archivo = "D:\archives\"
      Set Filename = Connection.Execute("Select obj_num FROM rest_def")
      Nombre = Filename.getString
      Archivo = "D:\archives\" + Nombre + ".txt"
      Set outputFile = objFSO.CreateTextFile(Archivo,True)
      outputFile.Write commandoSQL &amp; vbCrLf
      outputFile.Close
      Call closeConnection()
  End Sub
  
  Sub startConnection()
      Set Connection = WScript.CreateObject("ADODB.Connection")
      Connection.Open "DSN=milo; UID=dataBase; PWD=password"
  End Sub
  
  Sub closeConnection()
      Connection.Close 
  End Sub
  </code></pre>
  
  <p>So if the data of Filename is 7890, I want the file to be named as 7890.txt with all the recordset written in the file... help please, this is my first attempt with vbs...</p>