
26/06/2008, 04:06
|
| | Fecha de Ingreso: mayo-2008
Mensajes: 9
Antigüedad: 16 años, 11 meses Puntos: 0 | |
introducir a base de datos numeros decimales Hola a todos:
tengo un problema a la hora de introducir unos valores con coma a la base de datos mysql. He ejecutado el programa paso a paso y veo que tengo en la variable tara tengo un valor (double) de 32.5 pero al introducirmelo en la base de datos me pone 32.00. como puedo solucionar esto? necesito alguna funcion especifica?? dejo aqui mi programa por si acaso ve alguien el fallo y puede ayudarme
Option Explicit
Public conexion As ADODB.Connection
Private Sub Form_Load()
Dim Linea As String
Dim retorno As String
Dim fecha As String, hora As String, codigoproducto As Integer, tara As Double, peso As Double, siguiente As Integer
Dim Sql_Insert, Sql_Select As String
Dim num_linea As Long
Dim rs As ADODB.Recordset
Set conexion = New ADODB.Connection
conexion.ConnectionString = "driver={MySQL ODBC 3.51 Driver};" & _
"server=localhost; " & _
"uid=root; " & _
"pwd=barroeta" & _
";database=pruebacon4lineas" & _
";OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
conexion.ConnectionTimeout = 5
conexion.Open
Set rs = New ADODB.Recordset
siguiente = 0
Open "C:\UNAPESADA.TXT" For Input As #1
Do Until EOF(1)
Line Input #1, Linea
Debug.Print Linea
If siguiente = 0 Then
fecha = Left(Linea, 7)
hora = Mid(Linea, 9, 5)
End If
If siguiente = 2 Then
codigoproducto = CInt(Mid(Linea, 5, 3))
tara = Val(Mid(Linea, 10, 5))
peso = Val(Mid(Linea, 16, 7))
End If
siguiente = siguiente + 1
Loop
Close #1
Sql_Select = "select max(idlinea) from lineas"
rs.Open Sql_Select, conexion, adOpenStatic, adLockOptimistic
Debug.Print rs.Fields(0)
num_linea = CLng(rs.Fields(0).Value)
num_linea = num_linea + 1
Sql_Insert = "INSERT INTO lineas(idlinea,tara, fecha, codigoproducto, peso, hora) Values(" & num_linea & _
"," & Val(tara) & ",'" & fecha & "'," & codigoproducto & "," & Val(peso) & ",'" & hora & "')"
conexion.Execute Sql_Insert
siguiente = 0
End Sub GRACIAS DE ANTEMANO |