Commandtext origin a overloaded execute reader

Sad
Hi, I have a OleDbCommand and I'm trying to add a sqlcommand with more than 1000 characters. When I execute the executereader() it give-me a overloaded error. If I reduce to less than 1000 characters it works perfectly. I don't know how to resolve this error. Can someone help me

Thanks.


Answer this question

Commandtext origin a overloaded execute reader

  • mciv34

    Hi,

    What exactly is the error Could you post a code snippet in which your program is generating the error It would help to speed up the process of finding the problem.




    cheers,

    Paul June A. Domag


  • Slybacon

    Hi,
    I have something like that

    OleDbConnection conn = new OleDbConnection(ConfigurationSettings.AppSettings["DSN"]);
                OleDbDataReader resultados=null;
                //VAI PEDIR A BD A INFORMACAO RELATIVA AO PEDIDO EM QUESTAO
                try
                {
                    string sqlText ="select PEDE.id,PEDE.anopedido, PEDE.codigopedido, PEDE.datapedido, PEDE.descricaoResumida, PEDE.descricaoPedido,PEDE.DataAtribuicao,PEDE.DataInicioPedido, " +
                        "APLIC.descricaoaplicacao,  " +
                        "USERS.nomeRequerente, " +
                        "RECEP.descricaoModoRecepcao, " +
                        "TP.descricaoTipoPedido, " +
                        "ESTADO.descricaoEstado, " +
                        "ATRIB.DescricaoAtribuicao, " +
                        "NFilesPedido = (select count(*) from PedidoFicheiro where PEDE.anopedido=anopedido and PEDE.codigopedido=codigopedido), " +
                        "nFilesResposta = (select count(*) from RespostaFicheiro where PEDE.anopedido=anopedido and PEDE.codigopedido=codigopedido)" +
                        "from " +
                        "pedidos PEDE, " +
                        "estados ESTADO, " +
                        "atribuidoA ATRIB, " +
                        "aplicacao APLIC, " +
                        "modorecepcao RECEP, " +
                        "requerentes USERS, " +
                        "tipopedido TP " +
                        "where PEDE.CodigoAplicacao = APLIC.CodigoAplicacao and PEDE.CodigoRequerente = USERS.codigoRequerente and " +
                        "PEDE.CodigoModoRecepcao = RECEP.CodigoModoRecepcao and PEDE.CodigoTipoPedido = TP.CodigoTipoPedido and " +
                        "PEDE.CodigoEstado = ESTADO.CodigoEstado and PEDE.CodigoAtribuicao = ATRIB.CodigoAtribuicao and " +
                        "(PEDE.codigoEstado <> 9 and PEDE.codigoestado <> 99) " + //q nao esteja concluido nem anulado
                        " and PEDE.codigoPedido = " + idpedido + " and PEDE.anopedido= " + ano +
                        " order by PEDE.anopedido desc, PEDE.codigoPedido desc";

                    //ABRE A LIGACAO
                   
                    conn.Open();
                    OleDbCommand myCommand = new OleDbCommand(sqlText,conn);
                    myCommand.CommandTimeout= 20;
                    resultados = myCommand.ExecuteReader(CommandBehavior.SingleResult | CommandBehavior.CloseConnection);

    When (in the command window) I ask at the var resultados if hashrows, it tell me that don't have any rows. I remove the order by clause and it works perfectly.
                   

  • Commandtext origin a overloaded execute reader