如何从sqldatareader一对一读取记录 [英] How to read records one by one from sqldatareader

查看:86
本文介绍了如何从sqldatareader一对一读取记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何通过单击下一个"和上一个"按钮从sqldatareader中读取记录,一个又一个?
在此先谢谢您.

Hi,

How to read records one bye one from sqldatareader by clicking Next and Previous button?

Thanks in advance.

推荐答案

注意:datareader仅适用于转发器
但是,即使不是,您也需要在请求之间以某种状态存储查询结果,或者重新查询数据库以获取上一个或下一个结果.
Note: datareader is f?arward only
But, even if it wasn''t, you need to either store the results of your query in some kind of state, between requests, or requery the database to get the previous or the next result.


你好罗摩克里希那,

将收集结果加载到要存储断开连接的数据的对象(泛型列表之类)中.从那里将控件绑定到该对象,从而增加或减少对象(列表) )下一个/上一个索引.

Riaan
Hi Ramakrishna,

Load your collection results into a object(genericlist or the likes) that you would like to store the disconnected data in. From there databind the control(s) to the object, increasing or decreasing your object(list) index with next/previous.

Riaan


不要这样做.由于datareader在连接模式下工作,因此只要用户使用下一个和上一个按钮浏览记录,与SQL Server的连接将处于活动状态.一旦超过连接限制,稍后在SQL Server上将拒绝新连接.

同样,datareader不允许您读取上一条记录,而仅允许下一条记录.

而是使用数据集并读取下一个和上一个按钮上的每个记录.
Don''t do that. Since datareader works in a connected mode, as long as the user is browsing the records with the next and previous buttons, the connenction with the SQL server will be active. Later on the SQL server will reject the new connections once the connection limit exceeds.

Again, datareader will not allow you to read a previous record.It will allow only the next record.

Instead use a dataset and read each records on next and previous button.


这篇关于如何从sqldatareader一对一读取记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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