当数据源不返回记录时,如何使用特定数量的行或记录填充数据集 [英] How to fill dataset with certain number of rows or records when datasource retuns no of records

查看:63
本文介绍了当数据源不返回记录时,如何使用特定数量的行或记录填充数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







如果我有一个存储过程,这不在我的控制之下,即服务器可能在其他地方返回千条记录。现在我想通过使用这个存储过程绑定数据集,但不想要总共千条记录而不是我只想要一百条记录。所以我的问题是没有修改存储过程...

Hi,


If i have one stored procedure,which is not under my control i.e server may be at other place returning thousand records. Now i want to bind dataset by using this stored procedure but do not want total thousand records instead of i want only hundred records. so my problem is with out modifying stored procedure...

推荐答案

我不认为你会找到一个不错的选择而不进入你不想要的东西进入。比如返回一个截断响应流或真正离墙的东西,无论如何都无法正常工作。我不是说这是可能的,但为了减少回复的响应大小,你必须做这样的事情,而无需访问sproc本身。我不知道无论如何根据连接字符串或sproc的execute方法来限制大小。但可能有办法。但这很奇怪。



我这里只看到几个选项。



1.)你能写另一个sproc只返回第一个sproc中的前100个吗?这可能比将一百万条记录带回应用程序更好。第一个sproc将选择一百万个记录,但第二个将在将其返回到您的应用程序之前减少它。但我怀疑你不能,因为它听起来不像你有任何控制数据库。



2.)如果无法修改区域sproc,除非将sproc作为可以传入的参数来控制它,否则无法限制返回的内容。是否有任何参数可以控制以减少记录数量?如果没有,可能会要求DBA修改sproc,以允许您发送一个参数,该参数可以用于返回给定的TOP计数...或者根据您的需要制作该sproc的第二个副本并限制它。但如果他们不会或你不能要求他们...那么也许有第三种选择...



3.)最后一个选择。 Jsut不要使用sproc!如果你只需要返回100条记录,也许你可以在没有sproc的情况下做到这一点。 sproc更快,但SQL查询可能只有100条记录。当然,假设很多。但是如果除了返回数千条记录之外别无选择,我会考虑它。你能确定sproc的工作原理,或者你有能力并自己编写查询吗?



除非我的经验以外有其他选项,我相信其中有,我想不出任何其他选择。真的是一个奇怪的要求。希望你能找到更好的方法。
I don't think you are going to find a good option without getting into something you do not want to get into. Such as returning a truncating the response stream or something really off the wall that proably wouldn't even work anyway. I'm not saying that is possible, but to reduce the response size coming back, you'd have to do something like that without having access to the sproc itself. I don't know of anyway to limit the size based on the connection string or execute method for the sproc. But there may be a way. But it would be odd.

I only see a couple of options here.

1.) Can you write another sproc to return only the first 100 from the first sproc? That might be better than having a million records come back to the application. The first sproc will select a million records, but the second one would reduce it before returning it to your app. But I suspect you cannot, as it doesn't sound like you have any control over the database.

2.) If you cannot modify the orgional sproc, there is no way to limit what it returns unless the sproc as parameters that you can pass in to control it. Are there any parameters you might be able to control to reduce the number of records? If not, maybe ask the DBA to modify the sproc to allow you to send in a param that the sproc could use to return a given TOP count... or make a second copy of that sproc for your needs and limit it. But if they will not or you cannot ask them to... then maybe there is a third option...

3.) One last option. Jsut don't use the sproc! If you only need to return 100 records, maybe you could do this without the sproc. The sproc is faster, but a SQL Query might be ok with only 100 records. Of course that assumes a lot. But I would consider it if I had no option other than returning thousands of records. Can you determine how the sproc works or do you have the ability and write a query yourself?

Unless there are options outside of my experiance, which I am sure there are, I cannot think of any other options. It is an odd requirement really. Hopefully you can find a better way.


这篇关于当数据源不返回记录时,如何使用特定数量的行或记录填充数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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