Problema al guardar decimales con BBDD Access
Publicado por Jose (3 intervenciones) el 26/06/2019 12:51:58
Mi problema es que al guardar un número decimal en Access lo omite. Si quiero guardar por ejemplo 1,25 este se convierte en la bbdd en 125,00. He revisado la configuración regional y el separador de decimales es la coma.
Este es el código que estoy usando:
Un saludo y gracias.
Este es el código que estoy usando:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Public Class NUEVOARTICULOTELEFONIA
Private Sub LineaspartetelfBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
Me.Validate()
Me.LineaspartetelfBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.AvisosDataSet)
End Sub
Private Sub NUEVOARTICULOTELEFONIA_Load(sender As Object, e As EventArgs) Handles MyBase.Load
txtParte.Text = INTERCAMBIO.ParteTelefonia
txtArticulo.Select()
'TODO: esta línea de código carga datos en la tabla 'AvisosDataSet.lineaspartetelf' Puede moverla o quitarla según sea necesario.
Me.LineaspartetelfTableAdapter.Fill(Me.AvisosDataSet.lineaspartetelf)
End Sub
Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles btnGuardar.Click
txtTotal.Text = CDbl(txtCantidad.Text) * CDbl(txtPrecio.Text)
Me.LineaspartetelfTableAdapter.agregararticulo(txtArticulo.Text, txtCantidad.Text, txtPrecio.Text, txtTotal.Text, txtParte.Text)
DETALLETELEFONIA.LineaspartetelfTableAdapter.filtroparte(DETALLETELEFONIA.AvisosDataSet.lineaspartetelf, txtParte.Text)
Dim linea As DataGridViewRow
Dim valor As Double
For Each linea In DETALLETELEFONIA.LineaspartetelfDataGridView.Rows
valor = valor + linea.Cells(3).Value
Next
DETALLETELEFONIA.txtTotalParte.Text = FormatNumber(valor, 2) & " €"
txtArticulo.Text = ""
txtCantidad.Text = ""
txtPrecio.Text = ""
txtTotal.Text = ""
txtArticulo.Select()
End Sub
Private Sub TxtCantidad_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtCantidad.KeyPress
If Char.IsNumber(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsSeparator(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub TxtPrecio_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPrecio.KeyPress
If Char.IsNumber(e.KeyChar) Then
e.Handled = False
ElseIf e.KeyChar = "." Then
e.KeyChar = ","
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsSeparator(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub BtnCerrar_Click(sender As Object, e As EventArgs) Handles btnCerrar.Click
Me.Close()
End Sub
End Class
Un saludo y gracias.
Valora esta pregunta


0