-2
I have a problem formatting values type R$ when sending to the data bank 11.50 in the data bank is type 1150.
This condition is from the send button to the database has a database management class cl_GestorBD
private void button1_Click(object sender, EventArgs e)
{
cl_GestorBD gestor = new cl_GestorBD(true);
int id_produto = gestor.ID_DISPONIVEL("compras", "id_compra");
List<cl_GestorBD.SQLParametro> parametro = new List<cl_GestorBD.SQLParametro>();
parametro.Add(new cl_GestorBD.SQLParametro("@atualizacao", DateTime.Now));
string PRODUTO;
int QTY;
decimal VALOR_UNID;
decimal VALOR_TOTAL;
try
{
foreach (ListViewItem caixa in listCaixa.Items)
{
PRODUTO = caixa.SubItems[0].Text;
QTY = Convert.ToInt32(caixa.SubItems[1].Text);
VALOR_UNID = Convert.ToDecimal(caixa.SubItems[2].Text);
VALOR_TOTAL = Convert.ToDecimal(caixa.SubItems[3].Text);
query = "INSERT INTO compras VALUES ('" + id_produto + "','" + lblID.Text + "', '" + PRODUTO + "', '" + QTY + "', '" + VALOR_UNID + "', '" + VALOR_TOTAL + "',@atualizacao)";
gestor.EXE_NON_QUERY(query, parametro);
}
MessageBox.Show("Registrado com sucesso!");
}
catch (Exception erro)
{
MessageBox.Show("ERRO " + erro.Message);
}
}
Try trading the comma for a point before sending to the bank
– Matheus Ribeiro
Please share the snippet of code that Voce is using, what types are you using, double, real, etc., usually like Matheus said point by comma, but you have to see how your code is to avoid replacing and doing it the right way.
– Thiago Loureiro
This? https://answall.com/q/81237/101. Of course, the solution may be different, but if you have 1150, and you want 11.50, you only have to divide by 100. Now, if the problem is that you’re getting the dice wrong maybe it’s more interesting to fix it.
– Maniero
from a glance there I just updated the information above
– Raphael Shembek
i changed the type in the money database to Numeric(15.2) so now when uploader appears an error message: Date Confailed version [OLE DB status value (if-know) = 0 ]
– Raphael Shembek
now I have changed the type of data bank Numeric(15.2) to int, data send and not error, so value 11.50 it stands as 115
– Raphael Shembek
Do not change anything for the whole, if the data has the corresponding type in the database do the way it has to be done, already caught there a number break, that will generate a big problem, care. Put in the decimal or corresponding database and do the conversion in the code and ready, missed tell which is your database and your code by the update has big problems, one of them is not using
Parameters
...– novic
@Raphaelshembek Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already done so. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site
– Maniero