.NET SQL CE Core - Not enough storage is available to complete this operation
I am using SQL CE to store data in my application. I got an error with the below code after executing it for around 3000 times:
"Not enough storage is available to complete this operation"
The error is happened on a LIVE application.
SqlCeConnection开发者_JAVA百科 connection;
SqlCeTransaction transaction;
try
{
    connection = new SqlCeConnection(connectionString);
    connection.Open();
    transaction = connection.BeginTransaction();
    SqlCeCommand deleteCmd = connection.CreateCommand(); 
    deleteCmd.CommandText ="Delete from EJData where ID=@id"; 
    deleteCmd.Parameters.Add("@id", SqlDbType.Int, Int32.MaxValue.ToString().Length, "ID"); 
    adapter.DeleteCommand = deleteCmd;
    adapter.DeleteCommand.Transaction = transaction;
    DataRow[] r = dataSet.Tables[0].Select("ID >=" + firstRecordID + " and ID<=" + lastRecordID); 
    foreach (DataRow row in r) 
    {
        row.Delete();
    }
    adapter.Update(dataSet,"EJData" ); 
    transaction.Commit(CommitMode.Immediate); 
    transaction.Dispose();
    transaction = null; 
} 
catch ( ... )
{
    ...
}
finally
{ 
    if (adapter.DeleteCommand != null) 
    {
        adapter.DeleteCommand.Dispose();
    }
    connection.Close();
}
when declaring the parameter use this: deleteCmd.Parameters.Add("@id", SqlDbType.Int, "ID");
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论