SQLCeException的存储空间不足



我在Windows Mobile 6.5设备上具有扫描仪应用程序。

我扫描100个项目后,该应用程序一直在崩溃(在此处打开SQLCE连接并执行SQL查询以填充临时数据,并查询结果)。

在这里我的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

您的内存不足。建议不建议将数据集与Windows Mobile一起使用,而是使用数组或列表。

最新更新