By João Evangelista Bezerra de Sousa - 10/3/2012
Hi,When I Save a Business Object in Transaction I recive this error: "Invalid attempt to read when no data is present" Please Help me to solve this problem. Implementation SysfileBO sysfileBO = new SysfileBO(); Int002BO int002BO = new Int002BO(); Int003BO int003BO = new Int003BO(); Esto011BO esto011BO = new Esto011BO(); Esto022BO esto022BO = new Esto022BO(); Esto023BO esto023BO = new Esto023BO(); Esto024BO esto024BO = new Esto024BO(); Int014BO int014BO = new Int014BO(); Esto02BO esto02BO = new Esto02BO(); Int0098BO int0098BO = new Int0098BO(); TabtribBO tabtribBO = new TabtribBO(); UnidadeBO unidadeBO = new UnidadeBO(); NfeXmlItemBO nfeXmlItemBO = new NfeXmlItemBO(); SaveUndoResult result; (...) nfeXmlItemBO.FillByParentPrimaryKey(ID); if (nfeXmlItemBO.MoveFirst()) { do { dt = esto02BO.GetByPrimaryKey(nfeXmlItemBO.COD_SISTEMA); if (dt.Rows.Count == 0) { dt = unidadeBO.GetByPrimaryKey(nfeXmlItemBO.COM_UND); if (dt.Rows.Count == 0) { unidadeBO.NewRow(); unidadeBO.UNIDADE = nfeXmlItemBO.COM_UND; unidadeBO.DESCRICAO = nfeXmlItemBO.COM_UND; } esto02BO.NewRow(); esto02BO.CODIGO = (int)++sysfileBO.NUM_PRODUTO; esto02BO.ITEM = (nfeXmlItemBO.DESCRICAO ?? "").Trim(); if (esto02BO.ITEM.Length > 50) { esto02BO.ITEM = esto02BO.ITEM.Substring(0, 50); } esto02BO.COD_BARRA = !string.IsNullOrWhiteSpace(nfeXmlItemBO.EAN) ? nfeXmlItemBO.EAN.Trim() : esto02BO.CODIGO.ToString().PadLeft(13, '0'); esto02BO.REFERENCIA = esto02BO.CODIGO.ToString().PadLeft(8, '0'); esto02BO.FABRICA = 1; esto02BO.GRUPO = 1; esto02BO.SUBGRUPO = 1; esto02BO.COR = 1; esto02BO.TAMANHO = 1; esto02BO.COD_LINHA = 1; esto02BO.UNIDADE = "UN"; esto02BO.TABTRIB = 1; esto02BO.NCM_SH = nfeXmlItemBO.NCM; nfeXmlItemBO.Edit(); nfeXmlItemBO.COD_SISTEMA = esto02BO.CODIGO; } } while (nfeXmlItemBO.MoveNext()); } result = SaveUndoResult.Success; if (sysfileBO.IsDirty) { result = sysfileBO.Save(true, transactionKey); } if (unidadeBO.IsDirty && result == SaveUndoResult.Success) { result = unidadeBO.Save(true, transactionKey); } if (int0098BO.IsDirty && result == SaveUndoResult.Success) { result = int0098BO.Save(true, transactionKey); } if (int003BO.IsDirty && result == SaveUndoResult.Success) { result = int003BO.Save(true, transactionKey); } if (esto02BO.IsDirty && result == SaveUndoResult.Success) { result = esto02BO.Save(true, transactionKey); // THE EXCEPTION IS RAISED HERE
|
By Ivan George Borges - 10/3/2012
Hi João Evangelista.
Have a look at the thread from this post and see if it helps.
http://forum.strataframe.net/FindPost11770.aspx
Abraços.
|
By João Evangelista Bezerra de Sousa - 10/4/2012
Hi Ivan,Thank you for help me, this post gives me a cue about my problem, but my problem was not solved. I'm using a legacy database and in all my tables has an identity field, but they are no longer used and the primary keys are another fields, when I mapped manually my tables I don't put these identity fields, in most of cases worked but in this particular case, didn't. When I saw this post that you showed me, I mapped the identity field in SF, but it gives me a different error: "Cannot insert explicit value for identity column in table 'ESTO02' when IDENTITY_INSERT is set to OFF.". I didn't assign the identity field. Any idea? . Abraços
|
By Ivan George Borges - 10/4/2012
Not sure if this is your case, but have a look at the DDT, then go to your Table Properties (right-click your table and then choose Table Property from the context menu). Once there, you could have the "Automated Primary Key Index Creation..." checked. Maybe you don't want that.
|
By João Evangelista Bezerra de Sousa - 10/5/2012
Thank you to try help me, but the problem continue .I changed this method to a Stored Procedure, this way worked perfectly. Abraços
|
By Ivan George Borges - 10/5/2012
Glad you got it working.
|
|