确定是否返回了多行 [英] Determine if more than one row returned

查看:69
本文介绍了确定是否返回了多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP / ADO应用程序查询SQL Server数据库。我想知道

最有效的方法来确定是否从

查询返回多行。如果返回多行,将向用户显示要处理的行的

选项。如果只返回一行,我想在这个阶段跳过

,并立即处理该行。


我可以想到多种方法实现这个(例如.recordcount),但是我是

寻找最简单,最有效的方法。


任何想法或建议


谢谢


CJM

I have an ASP/ADO application querying an SQL Server DB. I want know the
most efficient way to determine if more than one row is returned from a
query. If more than one row is returned, the user will be presented with a
choice of which row to process. If only one row is returned, I want to skip
this stage, and process that single row immediately.

I can think of a number of ways of acheiving this (eg. .recordcount) but I''m
looking for the slickest and most efficient method.

Any thoughts or suggestions

Thanks

CJM

推荐答案

CJM写道:
我有一个ASP / ADO应用程序查询SQL Server数据库。我想知道
最有效的方法来确定查询是否返回了多行。如果返回多行,则将向用户显示要处理的行。如果只返回一行,我想跳过这个阶段,立即处理那一行。

我可以想到多种方法来实现这一点(例如.recordcount)
但我正在寻找最简洁,最有效的方法。

任何想法或建议
I have an ASP/ADO application querying an SQL Server DB. I want know
the most efficient way to determine if more than one row is returned
from a query. If more than one row is returned, the user will be
presented with a choice of which row to process. If only one row is
returned, I want to skip this stage, and process that single row
immediately.

I can think of a number of ways of acheiving this (eg. .recordcount)
but I''m looking for the slickest and most efficient method.

Any thoughts or suggestions



最佳选择:使用一个只返回数据的存储过程,如果比符合条件的行更多,则只返回



第二好:

使用GetRows将记录集数据放入一个数组中,并使用ubound函数检查其上限
索引。

这有一个额外的好处,允许你:

1.使用高效的服务器端前向游标(不支持
支持recordcount)

2.立即关闭并销毁记录集


-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。我的From

标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。


Best option: Use a stored procedure that only returns the data if more
than one row meeting the criteria exist.

Second best:
Use GetRows to put the recordset data into an array and check its upper
index bound using the ubound function.
This has the added benefit of allowing you to:
1. use the efficient server-side forward-only cursor (which does not
support recordcount)
2. immediately close and destroy the recordset

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don''t check it very often. You will get a
quicker response by posting to the newsgroup.




" Bob Barrows [MVP] " <再****** @ NOyahoo.SPAMcom>在消息中写道

news:O

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:O


************** @ TK2MSFTNGP04.phx.gbl ...
**************@TK2MSFTNGP04.phx.gbl...


最佳选择:使用只返回数据的存储过程,而不是符合条件的行。

第二好:
使用GetRows将记录集数据放入一个数组中,并使用ubound函数检查其上限索引。
这有一个额外的好处,允许你to:
1.使用高效的服务器端前向游标(不支持recordcount)
2.立即关闭并销毁记录集


Best option: Use a stored procedure that only returns the data if more
than one row meeting the criteria exist.

Second best:
Use GetRows to put the recordset data into an array and check its upper
index bound using the ubound function.
This has the added benefit of allowing you to:
1. use the efficient server-side forward-only cursor (which does not
support recordcount)
2. immediately close and destroy the recordset



鲍勃,


感谢您的回复...


选项2在这种情况下是最好的..可能只有一行返回

(这很好)但在这种情况下我需要以不同的方式处理它...


谢谢


Chris


Bob,

Thanks for the response...

Option 2 is the best in this case... there may only be one row returned
(which is fine) but in this case I need to handle it differently...

Thanks

Chris


这篇关于确定是否返回了多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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