Fields Currency 1,99 saving as 199 in Access

1

I'm having a problem when I'm going to save the data from currency or decimal fields to an Access database using the Visual Studio components.

When saving something of type 1.99m or has 1,99 in textbox the data goes to the bank as 199 . In short the comma is removed and I get the values multiplied by 100. How can I solve this? I already tried things like decimal.parse and Convert.toDecimal in addition to directly playing the data in querys I created:

tableAdapterprodutosTableAdapter.UpdateEstoquePreco(id, **1.99m**);

The problem occurs in any operation both insert and update .

    
asked by anonymous 23.08.2014 / 16:40

2 answers

2

I solved editing directly in the DataSet Designer, somehow he was setting the providerType for Numeric, all I did was change to currency

    
24.08.2014 / 01:14
1

Searching I found the following material, however as I used the tableAdapter components and datasets throughout the system I can not apply this! but follow the code!

public void Gravar(String Nome, DateTime Data, Decimal Salario, Boolean Status)
{
  using (OleDbConnection Conexao = new OleDbConnection(StringConexao))
  {
    Conexao.Open();
    using (OleDbCommand Commando = Conexao.CreateCommand())
    {
        Commando.CommandType = CommandType.Text;
        Commando.CommandText = "INSERT INTO Valores(Nome, Data, Salario, Status) VALUES(@Nome, @Data, @Salario, @Status);";
        Commando.Parameters.Add("@Nome", OleDbType.VarChar, 50).Value = Nome;
        Commando.Parameters.Add("@Data", OleDbType.Date).Value = Data;
        Commando.Parameters.Add("@Salario", OleDbType.Currency).Value = Salario;
        Commando.Parameters.Add("@Status", OleDbType.Boolean).Value = Status;
        Commando.ExecuteNonQuery();
    }
    Conexao.Close();
  }
}
    
23.08.2014 / 18:08