是否可以使用 JavaScript 和 cscript 枚举 ADO Recordset 的字段名称?
我正在编写一些在旧的 Windows NT 机器上运行的脚本。我计划使用基于命令的脚本主机(cscript)来执行它们。该脚本正在查询一些 SQL 数据,我想从记录集中检索字段名称,但它似乎不起作用。
这是我正在使用的代码:
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();
编辑:
也尝试过:
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();
}
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();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
..然后通过索引进行交互。
Try this:
..then interate through the index.