检索 ADO 记录集字段名称(经典 ASP) [英] Retrieve ADO Recordset Field names (Classic ASP)

查看:23
本文介绍了检索 ADO 记录集字段名称(经典 ASP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人可以提供帮助:

I wonder if someone can help:

长话短说,我正在使用 MSSQL2005 构建数据透视表.正在检查的数据受日期范围的限制(从最近的星期一到所选日期的 1 周内的所有数据)

Long story short, I'm using MSSQL2005 to build a Pivot table. The data being examined is limited by date range (All data for 1 week starting from the nearest Monday to the date selected)

当我运行存储过程并传递一个日期时,我得到正确的表,例如:

When I run the Stored Proc and pass it a date, I get The correct table back eg:

<头>
时间09 年 1 月 1 日09 年 1 月 2 日09 年 1 月 3 日...
09:000925...
09:3082765...
10:002044112...

我遇到的唯一问题是列标题会根据传递给 SP 的日期(所需的查看日期)和 SP 内部的逻辑(强制左侧列是最近的星期一)而有所不同到指定的日期).

The only problem I have is that the column headers will vary based on both the date passed in to the SP (The desired view date) and the logic inside the SP (which forces the left-hand column to be the nearest Monday to the date specified).

这意味着当我向用户显示结果时,我(当前)需要复制经典 ASP 中的日期检查逻辑[简单但可维护性失败]

This means that when I display the results to the user, I (currently) need to duplicate the date-checking logic in classic ASP [easy but a maintainability fail]

我真正需要的是一种从记录集中检索列名的方法.

What I really need is a way of retrieving the column names from the recordset itself.

有人可以指点我正确的方向吗?

Can someone please point me in the right direction?

我在 Google 上搜索过,但我得到的所有结果似乎都与读取表架构有关 - 在这种情况下这无济于事,因为我的表是在内存中动态生成的.

I've Googled but all the results I get seem to relate to reading a Table Schema - which doesn't help in this case as my table is being generated on the fly in memory.

非常感谢您提供的任何帮助

Many thanks in advance for any help you can provide

推荐答案

给定一个 ado 记录集,您可以大致执行以下操作(这是在伪代码中):

Given an ado record set you could do roughly the following (This is in psuedo code):

foreach (field in rs.Fields)
{
    alert(field.Name);
}

这将为您提供该字段的名称,请查看此文档.

This will give you the name of the field check out this documentation.

这篇关于检索 ADO 记录集字段名称(经典 ASP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆