Error on Save in Transaction


Author
Message
João Evangelista Bezerra...
João Evangelista Bezerra de Sousa
StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)
Group: StrataFrame Users
Posts: 8, Visits: 65
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
}

(...)




Best regards

João Evangelista
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
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.
João Evangelista Bezerra...
João Evangelista Bezerra de Sousa
StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)
Group: StrataFrame Users
Posts: 8, Visits: 65
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?

http://forum.strataframe.net/Uploads/Images/3ffce99f-3e53-4796-9b1f-135c.png.

Abraços

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
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.

http://forum.strataframe.net/Uploads/Images/263dbaef-a8ed-46cc-91e7-4944.png
João Evangelista Bezerra...
João Evangelista Bezerra de Sousa
StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)
Group: StrataFrame Users
Posts: 8, Visits: 65
Thank you to try help me, but the problem continue Smile.
I changed this method to a Stored Procedure, this way worked perfectly.



Abraços
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Glad you got it working. Wink
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search