I am writing some scripts to run on old Windows NT machines. I am planning on using the command-based script host (cscript) to execute them. The script are querying some SQL data and I want to retrieve the field names from the RecordSet, but it doesn't seem to work.
This is the code I'm using:
rs.open(query, conn, adOpenForwardOnly, adLockReadOnly);
rs.MoveFirst();
while(!rs.eof) {
for(field in rs.Fields) {
WScript.Echo(field.Name); /* outputs nothing */
}
WScript.Echo(rs.Fields("column")); /* outputs the column value for this record (as expected)*/
rs.MoveNext();
}
rs.close();
Edit:
Tried this as well:
while(!rs.eof) {
WScript.Echo(rs.Fields.length); /* doesn't print anything */
for(var i = 0; i< rs.Fields.length; i++) { /* loop isn't entered */
WScript.Echo(rs.Fields(i).Name);
}
rs.MoveNext();
}