如果基础游标不可滚动,SQL Server Compact 不支持调用 HasRows 属性。”
这实际上意味着什么?
我正在单步执行一些代码,当我在 vs2010 中的本地窗口下查看数据读取器的属性时,DR.HasRows 显示错误:
HasRows '(DR).HasRows' threw an exception of type 'System.InvalidOperationException' bool {System.InvalidOperationException}
base {"SQL Server Compact does not support calls to HasRows property if the underlying cursor is not scrollable."} System.SystemException {System.InvalidOperationException}
WHat 是光标,如何使其可滚动? :)
What does this actually mean?
I am stepping through some code and when I look at the properties of my datareader under the locals window in vs2010, the DR.HasRows shows an error:
HasRows '(DR).HasRows' threw an exception of type 'System.InvalidOperationException' bool {System.InvalidOperationException}
base {"SQL Server Compact does not support calls to HasRows property if the underlying cursor is not scrollable."} System.SystemException {System.InvalidOperationException}
WHat is a cursor and how do I make it scrollable? :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我之前遇到过这个错误,这是解决方案:
I got this error before and this is the solution:
更好的解决方案是强制结果集可滚动。这样做:
此处了解光标类型
A better solution would be to force the result set into being scrollable. Do it this way:
Read about what types of cursors there are here
只需在 while 循环中使用 DR.read() 即可。如果你的查询设置正确,你知道它只会运行一次,但如果你想进一步控制它,只需在读取你的数据后使用break:
Just use a DR.read() in a while loop. If your query is set properly, you know it will only run once, but if you want to control it even further, simply use break after reading youd data: