【发布时间】:2014-10-20 22:28:35
【问题描述】:
我在 Windows Mobile 6.5 设备上安装了扫描仪应用程序。
在我扫描大约 100 个项目后,应用程序不断崩溃(我打开 SqlCe Connection 并执行 SQL 查询以使用查询结果填充临时 DataTable)。
我的 C# 代码如下所示:
// Search with SQL
modFunctions.tempItemTable = new AppScanDataSet.itemDataTable();
string connectionString = @"Data Source='" + modFunctions.AppPath() + "AppScan.sdf'; Max Database Size = 512; Max Buffer Size = 4096;";
string strSql = "SELECT * FROM item WHERE Barcode = '" + modFunctions.strBarcode + "'";
using (SqlCeConnection mConnection = new SqlCeConnection(connectionString))
{
mConnection.Open();
//SqlCeConnection mConnection = new SqlCeConnection(connectionString);
SqlCeCommand mCommand = new SqlCeCommand(strSql, mConnection);
// Read all rows from the table into a dataset (note, the adapter automatically opens connection)
SqlCeDataAdapter adapter = new SqlCeDataAdapter(mCommand);
adapter.Fill(modFunctions.tempItemTable);
mConnection.Close();
mConnection.Dispose();
}
崩溃错误是:
AppScan.exe
SqlCeException
Not enough storage is available to complete this operation
可能是什么问题?我正在清除 tempItemTable(使用 Dispose() 和 Clear())。我还添加了mConnection.Close() 和mConnection.Dispose()...但没有帮助。
此外,当我转到设置 > 系统 > 内存时。当应用程序崩溃时,我似乎有足够的可用内存(100MB 中的 30MB)。
我需要处置adapter吗?还是mCommand?
【问题讨论】:
-
尝试从异常(哪一行、堆栈跟踪、InnerException)中获取更多信息。另外,条形码是唯一的吗?表中有大的 Blob 列吗?
-
AppScan.sdf 文件的大小是多少?
标签: c# sql-server-ce system.data.datatable