Actualizar registros con valores numericos decimales
Publicado por Alberto Domingo (9 intervenciones) el 26/05/2017 16:23:15
En Visual Basic 2010 puedo ingresar registros con campos que contienen valores decimales, pero cuando quiero modificar estos valores con UPDATE me da un error de sintaxis.
ReferTableadapter = New OleDbDataAdapter
ReferTableadapter.SelectCommand = New OleDbCommand("SELECT * FROM REFERENCIAS order by CODIREF1", miConexion)
Me.ReferTableadapter.UpdateCommand = New OleDbCommand
Defino las variables como Double, que admite decimales, inDistanciaV y inSegMedicionV
Defino el SQL
Tambien he probado definiendo las variables como Decimal y convirtiendo el valor de la caja de texto con CDec
Agradezco si alguien puede darme algún consejo de como evitar este error
ReferTableadapter = New OleDbDataAdapter
ReferTableadapter.SelectCommand = New OleDbCommand("SELECT * FROM REFERENCIAS order by CODIREF1", miConexion)
Me.ReferTableadapter.UpdateCommand = New OleDbCommand
Defino las variables como Double, que admite decimales, inDistanciaV y inSegMedicionV
1
2
3
4
5
6
7
8
9
10
11
12
13
inCodRefV = CDbl(inCodRef.Text)
inKMV = inKM.Text
InPosteV = InPoste.Text
InSimboloV = InSimbolo.Text
inDetalleV = inDetalle.Text
inDetalle1V = inDetalle1.Text
inDetalle2V = inDetalle2.Text
inDistanciaV = CDbl(inDistancia.Text)
inSegMedicionV = CDbl(inSegMedicion.Text)
inObservaV = inObserva.Text
inVelocidadV = CInt(inVelocidad.Text)
inCodRef1V = CDbl(inCodRef1.Text)
inCodicompetV = CDbl(inCodicompet.Text)
Defino el SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
SQLEd = "UPDATE REFERENCIAS SET CODIREF = " & inCodRefV & ", KLMETRO = '" & inKMV & "', "
SQLEd = SQLEd + "POSTE = '" & InPosteV & "', SIMBOLO = '" & InSimboloV & "', "
SQLEd = SQLEd + "COLOR = '" & inDetalleV & "', DETALLE1 = '" & inDetalle1V & "', "
SQLEd = SQLEd + "DETALLE2 = '" & inDetalle2V & "', DISTANCIA = " & inDistanciaV & ", "
SQLEd = SQLEd + "SEGMEDICION = " & inSegMedicionV & ", OBSERVA = '" & inObservaV & "', "
SQLEd = SQLEd + "VELOC = " & inVelocidadV & ", CODICOMPET = " & inCodicompetV & " "
SQLEd = SQLEd + "WHERE CODIREF1 = " & inCodRef1V & ""
ReferTableadapter.UpdateCommand.CommandText = SQLEd
dsRefer.Tables("tbRefer").Rows(0)("CODIREF") = inCodRefV
dsRefer.Tables("tbRefer").Rows(0)("KLMETRO") = inKMV
dsRefer.Tables("tbRefer").Rows(0)("POSTE") = InPosteV
dsRefer.Tables("tbRefer").Rows(0)("SIMBOLO") = InSimboloV
dsRefer.Tables("tbRefer").Rows(0)("COLOR") = inDetalleV
dsRefer.Tables("tbRefer").Rows(0)("DETALLE1") = inDetalle1V
dsRefer.Tables("tbRefer").Rows(0)("DETALLE2") = inDetalle2V
dsRefer.Tables("tbRefer").Rows(0)("DISTANCIA") = inDistanciaV
dsRefer.Tables("tbRefer").Rows(0)("SEGMEDICION") = inSegMedicionV
dsRefer.Tables("tbRefer").Rows(0)("OBSERVA") = inObservaV
dsRefer.Tables("tbRefer").Rows(0)("VELOC") = inVelocidadV
dsRefer.Tables("tbRefer").Rows(0)("CODICOMPET") = inCodicompetV
ReferTableadapter.UpdateCommand.Connection = miConexion
ReferTableadapter.Update(dsRefer.Tables("tbRefer")) 'Aquí se produce el error de sintaxis en UPDATE
Tambien he probado definiendo las variables como Decimal y convirtiendo el valor de la caja de texto con CDec
Agradezco si alguien puede darme algún consejo de como evitar este error
Valora esta pregunta


0