This is a migrated thread and some comments may be shown as answers.

Submitoperaton failed exception has been thrown by the target of an Invocation

1 Answer 61 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nelson
Top achievements
Rank 1
Nelson asked on 07 Nov 2011, 08:11 PM
Hi there,

In my silverlight application I need to save in database one object of type "ASSUNTOS". However I don´t know way, the application give this error and don´t save.
Submit Operaton failed exception has been thrown by the target of an Invocation. (in image).

And here are my code to do that:

  public void DF_EditEnding(object sender, Telerik.Windows.Controls.Data.DataForm.EditEndingEventArgs e)
        {
            this.VisibilidadeBotoes = Telerik.Windows.Controls.Data.DataForm.DataFormCommandButtonsVisibility.Add |
                                        Telerik.Windows.Controls.Data.DataForm.DataFormCommandButtonsVisibility.Edit |
                                        Telerik.Windows.Controls.Data.DataForm.DataFormCommandButtonsVisibility.Delete |
                                        Telerik.Windows.Controls.Data.DataForm.DataFormCommandButtonsVisibility.Commit |
                                        Telerik.Windows.Controls.Data.DataForm.DataFormCommandButtonsVisibility.Cancel;

            if (e.EditAction == Telerik.Windows.Controls.Data.DataForm.EditAction.Commit)
            {
                if (this.novoItem)
                {
                    bool i;
                    Assuntos assuntos = new Assuntos();
                    assuntos.IdProp = -1;
                    assuntos.ReuniaoIdProp = AppGlobais.Globais.reuniaoGlobal.IdProp;
                    assuntos.DesignacaoProp = AssuntoSeleccionado.DesignacaoProp;
                    assuntos.ConteudoProp = AssuntoSeleccionado.ConteudoProp;
                    assuntos.ConclusoesProp = AssuntoSeleccionado.ConclusoesProp;
                    assuntos.EmVotacaoProp = AssuntoSeleccionado.EmVotacaoProp;
                    assuntos.NumeracaoProp = AssuntoSeleccionado.NumeracaoProp;
                    assuntos.AprovadoProp = 1;
                    assuntos.AprovadoEmProp = DateTime.Now;
                    assuntos.AprovadoPorProp = AppGlobais.Globais.participanteReuniao.IdProp;
                    assuntos.ActivoProp = 0;
                    assuntos.ImportadoDocumentoProp = AssuntoSeleccionado.ImportadoDocumentoProp;
                    assuntos.PossuiVotacaoProp = AssuntoSeleccionado.PossuiVotacaoProp;
                    assuntos.TipoassuntoIdProp = AssuntoSeleccionado.TipoassuntosProp.IdProp;
                    assuntos.SugeridoEmProp = AssuntoSeleccionado.SugeridoEmProp;
                    assuntos.SugeridoPorProp = AppGlobais.Globais.participanteReuniao.IdProp;
                    assuntos.SitProp = 1;
                    assuntos.InsDataProp = DateTime.Now;
                    assuntos.InsUserProp = AppGlobais.Globais.Utilizador.LoginProp;
                    assuntos.AltDataProp = null;
                    assuntos.AltUserProp = null;
                    assuntos.VersaoProp = 0;
                    assuntos.PossuiTomadaConhecimentoProp = AssuntoSeleccionado.PossuiTomadaConhecimentoProp;


                    assuntoGuardado = assuntos;

                    if (assuntos.AprovadoProp == 1)
                    {

                        assuntos.AprovadoEmProp = DateTime.Now;
                        assuntos.AprovadoPorProp = AppGlobais.Globais.participanteReuniao.IdProp;
                    }

                    AppGlobais.Globais.ContextoSGA.Assuntos.Add(assuntos);
                   
                    BloquearLeituraEscritaDados = true;
                   this.novoItem = false;
                }

And in EditEnded I do the submit:

 public void DF_EditEnded(object sender, Telerik.Windows.Controls.Data.DataForm.EditEndedEventArgs e)
        {
            this.VisibilidadeBotoes = Telerik.Windows.Controls.Data.DataForm.DataFormCommandButtonsVisibility.Add |
                                         Telerik.Windows.Controls.Data.DataForm.DataFormCommandButtonsVisibility.Edit |
                                         Telerik.Windows.Controls.Data.DataForm.DataFormCommandButtonsVisibility.Delete;

            if (e.EditAction == Telerik.Windows.Controls.Data.DataForm.EditAction.Commit)
            {
                AppGlobais.Globais.ContextoSGA.SubmitChanges(SubmitCompleted, null);
            }
            else
            {
                this.AppGlobais.Globais.ContextoSGA.RejectChanges();


Please I need really help here.

Thanks in advance.

Nelson Silva

1 Answer, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 10 Nov 2011, 07:24 PM
Hello Nelson,

 I am afraid that the error is too generic and will not help us in any way determine the cause of the error. It seems that during the commit of your data an error occurs on your server that can be caused by either a concurrency issue or a violation of a constraint. To be able to see the actual error it would be much easier if you put a break point in your call back method for the completed event and there you should be able to see the real error.

Kind regards,
Petar
the Telerik team

NEW and UPDATED OpenAccess ORM Resources. Check them out!

Tags
Development (API, general questions)
Asked by
Nelson
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Share this question
or