Query Problem C#/Postgres

Asked

Viewed 48 times

-1

I have the following method:

 private static List<ProdutosTmpModel> GetInListaPromo_caddespd(Dados dados, Empresa emp)
    {
        //busca todas os produtos das listas vigentes
        StringBuilder command1 = new StringBuilder();

        command1.Append(" SELECT  a.cod_filial, " +
                                  " a.cod_reduzido," +
                                   " a.prc_desconto," +
                                   " b.vlr_custo," +
                                   " b.prc_lucro, " +
                                   " b.vlr_venda," +
                                   " a.vlr_promocao," +
                                   " b.cod_barra," +
                                   " a.dat_fim" +
                      " FROM produto1 AS a" +
                      " INNER JOIN produto2 as b  on a.cod_reduzido = b.cod_reduzido" +
                        " WHERE a.cod_filial = " + emp.filial +
                      " AND a.dat_fim >= NOW()" +
                      " ORDER BY a.dat_fim; ");

        _GetInListaPromo = command1.ToString();

        NpgsqlConnection conn = ConectionTrier.npgSqlConection(dados.host, "5432", dados.banco, dados.usuario, dados.senha);

        conn.Open();

        NpgsqlCommand cmd = new NpgsqlCommand(command1.ToString(), conn);
        NpgsqlDataReader reader;
        reader = cmd.ExecuteReader();
    }

when I run this method on the client’s pc, where this ">" is placed " u003e" causing a sql error, however on my pc it does not happen, how can I fix it ?

in the image below it is possible to see the executed command: inserir a descrição da imagem aqui

  • your ENCODING is wrong... try to set the bank encoding to UTF8

  • I do not have autonomy for changes in the bank, can you tell me if there would be some way to "force" the ">" ? via code

  • Replace images with text, otherwise anyone who tries to reproduce the problem will need to type TD.

  • what error is causing? and turning into JSON does not mean that it is going wrong.

  • Virgilio, gives syntax error, because when executing the character ">" is replaced by " u003e"

  • Dude, take a look: https://answall.com/questions/321194/como-definir-o-set-client-encoding-utf8-de-forma-permanent I hope it helps

Show 1 more comment

1 answer

-3

Try putting the following in the Connection string:

Encoding=UNICODE

Vi here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.