Is giving this error "EntityException was unhandled -An error occurred while starting a transaction on the provider connection. See the inner exception for details."on this code:
"
foreach (Funcionario fn in contexto.Funcionario){
int existe = 0;
foreach (Ponto pt in contexto.Ponto.Where(pnt => pnt.NFuncionario == fn.ID && pnt.Data == datePicker3.SelectedDate))
{
existe++;
//MessageBox.Show("Encontrou.");
}
if (existe != 1) {
int criou = 0;
foreach (Feria fe in contexto.Feria.Where(f => f.Funcionario.ID == fn.ID && f.DataInicio <= datePicker3.SelectedDate && f.DataFim >= datePicker3.SelectedDate))
{
Ponto ptf = new Ponto();
ptf.Estado = "Férias";
ptf.Data = ((DateTime)datePicker3.SelectedDate);
ptf.NFuncionario = fn.ID;
ptf.Visto = true;
contexto.Ponto.AddObject(ptf);
//contexto.SaveChanges();
criou = 1;
}
if (criou != 1) {
foreach (MarcarOutro ou in contexto.MarcarOutro.Where(o => o.Funcionario.ID == fn.ID && o.DataInicio <= datePicker3.SelectedDate && o.DataFim >= datePicker3.SelectedDate))
{
Ponto ptf = new Ponto();
ptf.Estado = ou.Nome;
ptf.Data = ((DateTime)datePicker3.SelectedDate);
ptf.NFuncionario = fn.ID;
ptf.Visto = true;
contexto.Ponto.AddObject(ptf);
//contexto.SaveChanges();
criou = 2;
}
}
if (criou == 0) {
Ponto pt = new Ponto();
pt.Estado = "Presente";
pt.Data = ((DateTime)datePicker3.SelectedDate);
pt.NFuncionario = fn.ID;
pt.Visto = false;
contexto.Ponto.AddObject(pt);
contexto.SaveChanges();
}
}
}
"