您的位置:首页 > 其它

Column 'column' does not belong to table Table

2007-11-06 14:48 399 查看
Server Error in '/' Application.
--------------------------------------------------------------------------------

Column 'C' does not belong to table Table.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Column 'gameIsNow' does not belong to table Table.

FROM:http://www.cnblogs.com/Sniper/archive/2006/03/06/343986.html

最近项目上遇到一个很奇怪的问题,查询经常性的出错,这种出错是间歇性的。比如在代码中写select column1 from talbe1。执行完毕后Fill一个DataSet,再访问DataSet中的Table和Row以及Column。通常会有一些莫名其妙的错误,例如
Can not find Table 0.
Column "column1" dose not belong to Table table.
在大多数情况下,没有任何问题,但是程序运行一会儿(不定期),就会出现这个问题。过一会儿可能也好了,但是几十分钟或几个小时后又出现了。
经过种种分析、排除,查找原因,最后把问题确定在connection.Close()的上。

SqlConnection.Close Method

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdatasqlclientsqlconnectionclassclosetopic.asp

CAUTION Do not call Close or Dispose on a Connection, a DataReader, or any other managed object in the Finalize method of your class. In a finalizer, you should only releaseunmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a Finalize method in your class definition. For more information, see Programming for Garbage Collection.

根据这个文章,我们注释了log(日志记录)处的Finalize中的connection的close方法。问题得以解决,但是其原理百思不得其解。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐