请问SQL CE ExecuteResultSet需要清理吗? [英] Does SQL CE ExecuteResultSet need to be cleaned up?
问题描述
我在这约150行的表。这些表中的数据类型:
I have a table with about 150 rows in it. These are the data types in the table:
- INT(PK)
- 为nvarchar(52)
- TINYINT
- 日期时间
- 的唯一标识符
- 为nvarchar(300)
- 位
- 位
- 位
- 位
- int (PK)
- nvarchar(52)
- tinyint
- datetime
- uniqueidentifier
- nvarchar(300)
- bit
- bit
- bit
- bit
我从Web服务下载数据并插入到数据库中。当我这样做,它工作正常。
I download the data from a web service and insert into the database. When I do that it works fine.
我后来在我的计划执行,我再次调用Web服务。因为我可能已经更新了一些我下载了第一次的数据,我检查了数据库,看看该行已更改。如果有那么我离开它,如果没有的话我更新。我认为这是检查是否是有,是造成我的问题。当我这样做,我得到这个错误:
I later in the execution of my program I call the web service again. Since I may have updated some of the data I downloaded the first time, I check the db to see the row has changed. If it has then I leave it, if not then I update it. I think it is the check to see if it is there that is causing me the problems. When I do it I get this error:
的SQL Server Compact已经通过修改SSCE超过了缓冲区的大小,默认大小可以增加在初始化:最大缓冲区大小属性[默认大小= 655360]
"SQL Server Compact has exceeded the buffer size. The default size can be increased on initialization by modifying the ssce: max buffer size property. [ The default size = 655360 ]"
请注意:这不会立即发生的第二次左右。 (意思是我踩通过一些行,它们更新就好了。)
NOTE: This does not happen right away on the second time around. (Meaning that I stepped through some rows and they updated just fine.)
我唯一能想到的是,我的结果集是没有得到清除出去。 (虽然我也用同样的code到,没有任何问题访问数据库。)
The only thing I can think of is that my result set is not getting cleared out. (Though I have used the same code to access the database with no problems.)
下面是我的code:
public static SqlCeResultSet SetupTable(string tableName, string indexName,
bool allowUpdates, params object[] whereValues)
{
// The command used to affect the data
var command = new SqlCeCommand
{
CommandType = CommandType.TableDirect,
Connection = _connection,
// Set the table that we are going to be working with.
CommandText = tableName,
// Indicate what index we are going to be using.
IndexName = indexName
};
if ((whereValues != null) && (whereValues.Length > 0))
command.SetRange(DbRangeOptions.Match, whereValues, null);
// Get the table ready to work with.
if (allowUpdates)
return command.ExecuteResultSet(
ResultSetOptions.Updatable | ResultSetOptions.Scrollable);
else
return command.ExecuteResultSet(ResultSetOptions.Scrollable);
}
调用看起来是这样的:
The call looks something like this:
SetupTable("tblMyTable", "IndexName", true, whereValue);
奇怪的是,这一切工作正常,如果我不使用SetRange。在我看来,它应该使用更少的缓冲空间,如果我使用SetRange(不多,因为它似乎是在做)。
The weird thing is that it all works fine if I don't use the SetRange. It seems to me that it should use less buffer space if I use a SetRange (not more as it seems to be doing).
在它在查询分析器此错误调用崩溃也将给予相同的消息。我可以我的缓冲区的大小,但我相信它只是需要更长的时间来填补(especally因为我传递一个,其中值设定范围为单排)。
After it crashes with this error calls in Query Analyzer will also give the same message. I could up my buffer size but I am sure it will just take a bit longer to fill up (especally because I am passing in a "where" value that sets the range to a single row).
有一点需要注意的是,我所说的上述code的每一行中我的表。 (这就是为什么我问我是否应该清理我的结果)。虽然我在我的桌子把它的每一行,previous人去了范围之前,我做一个新的。
One thing to note is that I call the above code for each row in my table. (That is why I am asking if I should be cleaning up my results.) While I do call it for each row in my table, the previous one goes out of scope before I make a new one.
任何帮助将是巨大的!
Any help would be great!
(注意:如果你想看到完整的code为SetupTable东西,我把全班这里。)
(Note: if you want to see the full code for the SetupTable stuff I put the whole class here.)
推荐答案
您的地方处理您的命令?
Are you disposing your command somewhere?
凡是实现IDisposable(具有Dispose()方法)应释放。这是一般规则。既然你调用此方法的每一行,你应该处理您的命令。
Anything that implements IDisposable (has a Dispose() method) should be disposed. That's the general rule. Since you're calling this method for every row, you should dispose your command.
这篇关于请问SQL CE ExecuteResultSet需要清理吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!