使用 getstring 在 ADO 中选择特定列

发布于 2024-07-09 05:29:02 字数 86 浏览 5 评论 0原文

当我们使用 getstring 从记录集 (ADO) 获取数据时,它会返回所有列。

如果只需要某些列,我们如何修改getstring语句?

When we use getstring to get data from a recordset (ADO) then it returns all the columns.

If only certain columns are required, how do we modify the getstring statement?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

偏爱你一生 2024-07-16 05:29:02

您可以后退一步,仅使用所需的字段(列)构建记录集,例如:

strSQL="SELECT ID, FName, SName FROM Members"
rs.Open strSQL, cn

a=rs.GetString

You can take a step back and build the recordset with only the fields (columns) that you want, for example:

strSQL="SELECT ID, FName, SName FROM Members"
rs.Open strSQL, cn

a=rs.GetString
你是我的挚爱i 2024-07-16 05:29:02

你不能。 GetString 返回所有或指定行数的所有列。 您需要循环遍历记录集,明确获取所需的列。

全部内容都在文档中。

You can't. GetString returns all columns of all or a specified number of rows. You'll need to loop through the recordset, getting the columns you want explicitly.

It's all in the documentation.

莫言歌 2024-07-16 05:29:02

您还可以使用 join 和 getrows 的组合

myString = join(rs.getrows( , , myColumn),";")
  • rsGetrows 返回一个仅包含 myColumn 值的数组
  • Join 将在一个数组中传输该数组
    像“value1;value2; ...”这样的字符串

检查确切的语法,因为这是即时编写的

编辑:不幸的是,它不能那么直接,因为 .getrows 将返回一个二维数组。 有没有可以从二维数组中提取一维数组的函数? 它很容易写,不是吗?

You can also use a combination of join and getrows

myString = join(rs.getrows( , , myColumn),";")
  • rsGetrows returns an array containing only the myColumn's values
  • Join will transfer the array in a
    string like "value1;value2; ..."

Check the exact syntax as this was written on the fly

EDIT: unfortunately, it cannot be that straight as .getrows will return a 2 dimensions array. Are there any functions that can extract a one dimension array from a 2 dimensions one? It can be written easily, can't it?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文