There is not enough memory to complete this operation in SQL Server CE

I am developing a headphone mute device application as I have two applications that both need to run at the same time and both have access to the same SQL Server CE file .sdf

.

If I run one by one, it works fine. But when running both SQL Server CE at the same time, the exception raises

There is not enough memory to complete this operation.

This is my code:

private void WriteToBD(string _serialNum, string _dataBytes)
{
   try
   {
      using (_con = new SqlCeConnection(@"Data Source=\NandFlash\PLCPackets.sdf;"))
      {
         _con.Open();

         string str = "insert into PLCPacket(SerialNum,Data) values('" + _serialNum + "','" + _dataBytes + "')";

         using (SqlCeCommand _cmd = new SqlCeCommand(str, _con))
         {
            //_cmd.CommandType = System.Data.CommandType.Text;
            int rowsAffected = _cmd.ExecuteNonQuery();
         }
      }
   }
   catch (Exception ex)
   {
      LogData.WriteFile(ex.Message);
   }
   finally
   {
      _con.Close();
      _con.Dispose();
   }
}

      

+3


source to share


1 answer


You can use mode=read write

explicitly in the connection string. You can find more information in this MSDN reference document .



+1


source







All Articles