I’m developing wince headless device application, in that I have two applications both should be running at a time and both are accessing same SQL Server CE .sdf file.
If I run one by one its works fine. But while running both at a time SQL Server CE exception is raising that
Not enough storage 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();
}
}
You can use
mode=read writeexplicitly in the connection string. You can find more information in this MSDN reference document.