Get numerical values from the database with comma and dots [FIREBIRD + C#]

Asked

Viewed 124 times

0

Hello, everyone. I’m having trouble retrieving the numerical values from the database in my Datagridview already formatted (including commas and dots).

The code that gets the data through a process and adds in my Datagridview is:

 string sql = "SELECT * FROM BUSCA_DETALHES_CARTEIRA(1, '1-JAN-2017', '31-JAN-2019', '1', 'N')";

        using (FbCommand command_ObtemDadosRel = new FbCommand(sql, ConexaoAoBanco))
        {
            ConexaoAoBanco.Open();

            using (IDataReader reader = command_ObtemDadosRel.ExecuteReader())
            {
                while (reader.

                    dataGridView1.Rows.Add(Convert.ToDouble(reader[2]));

                }
            }
        }

Values directly in my database are formatted already (with semicolons):

inserir a descrição da imagem aqui

But in the Datagridviewgets like this:

inserir a descrição da imagem aqui

The details are: I’ve tried using the conversion option for Decimal dataGridView1.Rows.Add(Convert.ToDecimal(reader[2]));

For the command of GetTypeCodeof Reader, returns to me that it is of the type Decimal

But I still tried Convert.ToDouble(reader[2])), dataGridView1.Rows.Add(reader.GetDecimal(2).ToString()), dataGridView1.Rows.Add(reader.GetDouble(2).ToString()); and also dataGridView1.Rows.Add(reader.GetFloat(2).ToString()) only for the discharge of conscience. Both did not work.

This column of my database where I read and add in Datagridview the records are of the type Numeric.

How can I get the values already with commas and dots? Need to adjust something at the time of reading the data or is some property itself Datagridview?

  • dataGridView1.Columns["Column1"].DefaultCellStyle.Format = "n";

  • Sorry to ask, but where should this code be located? At which event?

  • I am a beginner.

No answers

Browser other questions tagged

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