title: VBScript Recordset Field Names and Length
body: <p>Using VBScript, I create a recordset from a SQL query through and ADO connection object. I need to be able to write the field names and the largest field length to a text file, essentially as a two dimensional array, in the format of FieldName|FieldLength with a carriage return delimiter, example:</p>
  
  <p>Matter Number|x(13)<br>
  Description|x(92)<br>
  Due Date|x(10)</p>
  
  <p>Whilst I am able to loop through the Columns and write out the field names, I cannot solve the issue of Field Length. Code as follows:</p>
  
  <pre><code>Set objColNames = CreateObject("Scripting.FileSystemObject").OpenTextFile(LF14,2,true)
  For i=0 To LF06 -1
    objColNames.Write(Recordset.Fields(i).Name &amp; "|x(" &amp; Recordset.Fields(i).ActualSize &amp; ")" &amp; vbCrLf)
  Next
  </code></pre>
  
  <p>in this instance it only writes the current selected Field Length.</p>