DataTableReader是当前数据表'不是Temptable'无效 [英] DataTableReader is invalid for current DataTable 'TempTable'

查看:396
本文介绍了DataTableReader是当前数据表'不是Temptable'无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到每当我的代码有效的DataTable对象创建DataTableReader以下错误:DataTableReader是当前数据表'不是Temptable无效的

I'm getting the following error whenever my code creates a DataTableReader from a valid DataTable Object:

的事情是,如果我重新启动我的机器,它工作正常的时间量无法确定,则与上述死亡。抛出这个错误代码可以一直在努力罚款小时,然后:爆炸。你得到这个错误。
它不限于一个行任;这是一个DataTableReader使用的每一个位置。此外,生产Web服务器上不会发生此​​错误 - 永远

The thing is, if I reboot my machine, it works fine for an undetermined amount of time, then dies with the above. The code that throws this error could have been working fine for hours and then: bang. you get this error. It's not limited to one line either; it's every single location that a DataTableReader is used. Also, this error does NOT occur on the production web server - ever.

这已经被我逼疯了一个星期的最好的部分,我已经没有。找到谷歌什么,可以帮助(我敢肯定的,这不是一个问题,编码)

This has been driving me nuts for the best part of a week, and I've failed to find anything on Google that could help (as I'm pretty positive this isn't a coding issue).

一些技术信息:

DEV盒:
Vista的32位(目前所有的Windows更新)
Visual Studio 2008中v9.0.30729.1 SP
的dotNet Framework 3.5 SP1中

DEV Box: Vista 32bit (with all current windows updates) Visual Studio 2008 v9.0.30729.1 SP dotNet Framework 3.5 SP1

SQL服务器:
的Microsoft SQL Server 2005标准版 - 9.00.4035.00(X64)
Windows 2003的64位(目前所有的Windows更新)

SQL Server: Microsoft SQL Server 2005 Standard Edition- 9.00.4035.00 (X64) Windows 2003 64bit (with all current windows updates)

Web服务器:
Windows 2003的64位(目前所有的Windows更新)

Web Server: Windows 2003 64bit (with all current windows updates)

任何帮助,想法或建议将不胜!感谢

Any help, ideas, or advice would be greatly appreciated!

更新1:

确定 - 是否尝试过,现在没有成功如下:

Ok - Have tried the following now with no success:

1:重新引导
2:SFC / SCANNOW
3:更改SQL服务器
4:尝试使用DataTableReaders
5不同的方法:清理解决方案

1: Rebooted 2: SFC / ScanNow 3: Changed SQL Servers 4: Tried a different method that uses DataTableReaders 5: Cleaned solution

我发现的唯一的事情,工作是复制和放大器;从主Visual Studio实例粘贴代码
,到另一个其中有一个简单的控制台应用程序。
然后,这和预期一样(查询数据库并获得结果进入一个DataTable,创建该表的datatablereader,然后调用.Read()...
所有这一切都工作过质疑hasrows。

The only thing I did find that worked was copy & pasting the code from the main Visual studio instance, into another which had a simple console app. This then worked as expected (queried database and got results into a dataTable, created a datatablereader on that table, then queried hasrows before calling .Read()... All of which worked.

我很努力,看看这是什么原因,因为没有代码错误 - 我100%肯定,因为它在发布到Web服务器运行完全

I am struggling to see what could cause this, as there are NO code faults - i'm 100% certain, as it runs perfectly when published to the webserver.

推荐答案

我想用一段时间(reader.read())可以解决您的问题。

I think using the while(reader.read()) may solve your problem.

if (myReader.HasRows)
   while (myReader.Read())
     Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0), myReader.GetString(1));
else
   Console.WriteLine("No rows returned.");
myReader.Close();

更新: $ b $从MSDN b也:
中的HasRows属性返回有关当前结果集的信息。如果DataTableReader包含多个结果集,您可以检查HasRows属性的值,你打电话后立即以NextResult方法将确定新的结果集是否包含行。

UPDATE: Also from msdn: The HasRows property returns information about the current result set. If the DataTableReader contains multiple result sets, you can examine the value of the HasRows property immediately after you call the NextResult method in order to determine whether the new result set contains rows.

使用的HasRows属性,以避免调用DataTableReader的Read方法的要求,如果有当前结果集内的任何行。

Use the HasRows property to avoid the requirement to call the Read method of the DataTableReader if there are no rows within the current result set.

DataTableReader.HasRows物业

这篇关于DataTableReader是当前数据表'不是Temptable'无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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