0

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?

madth3
  • 7,275
  • 12
  • 50
  • 74
22332112
  • 2,337
  • 5
  • 21
  • 42
  • Try to get a little more info from the Exception (which line, stack trace, InnerException). Also, are the Barcodes unique? Are ther big Blob columns in the table? – H H Jan 29 '14 at 22:07
  • What is the size of your AppScan.sdf file? – Dour High Arch Jan 30 '14 at 00:55

1 Answers1

2

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

ErikEJ
  • 40,951
  • 5
  • 75
  • 115