Question

I have scanner application on Windows Mobile 6.5 device.

The application keeps crashing after I scan 100 items or so (where I open SqlCe Connection and execute SQL query to populate temporary DataTable with query result).

Here how my C# code looks like:

// 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();
}

Error on crash is:

AppScan.exe
SqlCeException
Not enough storage is available to complete this operation

What can be the problem? I am clearing out tempItemTable (with Dispose() and Clear()). I also added mConnection.Close() and mConnection.Dispose()... but it didn't help.

Also, when I go to Settings > System > Memory.. when application crashed, it seems like I have enough memory available (30MB out of 100MB).

Do I need to dispose adapter? or mCommand?

Was it helpful?

Solution

You are running out of memory. Using DataSet with Windows Mobile is not recommnded, use array or list instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top