VBA Migration to C # - V10 - Error "System.IndexOutOfRangeException: 'Can not find table 0.'"

1

Good afternoon, I needed help to help overcome error:

  

System.IndexOutOfRangeException: 'Can not find table   0. '", when executing PSO.ExecSql.ExecutaXML (" update CabLiq setPag="" + PSO.Utils.FStr (this.DocumentoVenda.CamposUtil ["CDU_SBModoPag"])   + "'where Id ='" + RessbIdCabLiq + "'");

Can anyone give me an idea?

public override void DepoisDeGravar(string Filial, string Serie, string Tipo, int NumDoc, ExtensibilityEventArgs e)
{
    string sSQLsbTipDocLiqAuto = null;
    string sSQLsbIdCabLiq = null;
    Guid RessbIdCabLiq = Guid.NewGuid();
    bool RessbTipDocLiqAuto = true;

    sSQLsbTipDocLiqAuto = ("SELECT LiquidacaoAutomatica from DocumentosVenda where Documento = '" + this.DocumentoVenda.Tipodoc + "'");

    if (BSO.Consulta(sSQLsbTipDocLiqAuto) != null) 
    {
        RessbTipDocLiqAuto = BSO.Consulta(sSQLsbTipDocLiqAuto).Valor(0);
    }

    if (RessbTipDocLiqAuto == true)
    {
        sSQLsbIdCabLiq = ("SELECT IdCabLiq from LinhasLiq where TipoDocOrig = '" + this.DocumentoVenda.Tipodoc + "' and NumDocOrigInt = '" + this.DocumentoVenda.NumDoc + "' " +
                          "and  SerieOrig = '" + this.DocumentoVenda.Serie + "' and  FilialOrig = '" + this.DocumentoVenda.Filial + "'");

        if (BSO.Consulta(sSQLsbIdCabLiq) != null)
        {
            RessbIdCabLiq = BSO.Consulta(sSQLsbIdCabLiq).Valor(0);
        }

    }              

    if ((!string.IsNullOrEmpty(PSO.Utils.FStr(this.DocumentoVenda.CamposUtil["CDU_SBModoPag"].Valor))) || (this.DocumentoVenda.CamposUtil["CDU_SBModoPag"].Valor != System.DBNull.Value))
    {
        if ((!string.IsNullOrEmpty(PSO.Utils.FStr(this.DocumentoVenda.CamposUtil["CDU_SBConta"].Valor))) || (this.DocumentoVenda.CamposUtil["CDU_SBConta"].Valor != System.DBNull.Value))
        {
            PSO.ExecSql.ExecutaXML("update CabLiq set ModoPag = '" + this.DocumentoVenda.CamposUtil["CDU_SBModoPag"].Valor + "' where Id = '" + RessbIdCabLiq + "'");
        }
        PSO.Dialogos.MostraAviso("ATENÇÃO!!!", StdBSTipos.IconId.PRI_Informativo, "Deve preencher corretamente os campos ''Modo de Pagamento'' e ''Conta''  que se encontra no separador Campos do Utilizador");
    }

    base.DepoisDeGravar(Filial, Serie, Tipo, NumDoc, e);
}
    
asked by anonymous 10.09.2018 / 19:35

1 answer

4

When using the ExecutaXML method, what is happening is that the query SQL is executing and then the result is returned in XML , which may be the source of your problem .

Since the goal is only to execute a UPDATE , without any return, first use the ExecuteSQL method:

BSO.DSO.ExecuteSQL($"UPDATE CabLiq SET ModoPag = '{this.DocumentoVenda.CamposUtil["CDU_SBModoPag"].Valor}' WHERE Id = '{RessbIdCabLiq}'");
    
10.09.2018 / 19:45