【问题标题】:SqlCeException Not enough storageSqlCeException 没有足够的存储空间
【发布时间】: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


【解决方案1】:

您的内存不足。不建议在 Windows Mobile 中使用 DataSet,而是使用数组或列表。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-24
    • 1970-01-01
    • 2014-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多