I have a small application running on several PCs for over a couple of years now, with a SQL Server CE 4 database file in a shared location. It's been working for a long time without issues, but now, and on a single PC, there are persistence issues.
Here's the code in question (it's really old code):
try
{
using (var context = new ClientFlowContainer())
{
Calls ct = context.CallsSet.Create();
ct.ClientId = _clientId;
if (Code.SelectedItem is Codes codes)
ct.Code = codes.Id;
ct.Data = DateTime.Today;
ct.Result = _msg + Resultado.Text;
ct.NextCall = checkBox1.Checked ? dateTimePicker1.Value : (DateTime?) null;
context.CallsSet.Add(ct);
context.SaveChanges();
}
}
catch (Exception ex)
{
while (ex != null)
{
MessageBox.Show(ex.Message);
ex = ex.InnerException;
}
}
There's no error message showing up so no exception is thrown - all other PCs work fine (and sometimes after some other PC runs this code then this PC can persist - but this is not garanteed)
So what could cause this behaviour? I'm thinking something external to my code but still I find it odd there's no error at all.
Any ideas?
EDIT 1:
As per request, here's the connection string:
in app.config, i have:
<connectionStrings>
<add name="ClientFlowContainer" connectionString="metadata=res://*/Data.ClientFlow.csdl|res://*/Data.MyDbFile.ssdl|res://*/Data.MyDbFile.msl;provider=System.Data.SqlServerCe.4.0;provider connection string="data source=|DataDirectory|\MyDbFile.sdf"" providerName="System.Data.EntityClient" />
</connectionStrings>
Then in code i do:
AppDomain.CurrentDomain.SetData("DataDirectory", "\\\\SERVER_NAME\\Path\\To\\DataBase\\File");