Problema con UPDATE executenonquery al actualizar un dato tipo double
Publicado por Antonio (3 intervenciones) el 10/09/2014 14:54:47
Hola buenos dias, estoy actualizando en ACCESS una base de datos que contiene dos columnas, ( Id(integer) y T1(double))
Hasta esta mañana estaba usando la variable T1 como integer, pero me di cuenta que tambien necesitaba decimales asique cambie el tipo de variable tanto en la tabla de access como en mi aplicacion de VB.
Sin embargo, una vez que cambio este tipo de dato ya no me funciona y me da el siguiente error.
tengo 2 textbox que recogen las dos columnas(Id y T1) , y posteriormente uso una funcion "Modificar Registro" a la cual he intentado pasarle el textbox correspondiente a T1 como string y como Double, pero no hay manera de que funcione.
Me dice que hay un error en la instruccion update de tipo System.Data.OleDbException (0x80040E14) :Error de sintaxis en la instruccion UPDATE.
A continuacon muestro mi funcion utilizada:
Function Modificar_Tiempo(ByVal Id As String, ByVal Tiempo As Double) As Boolean
'1.NECESITAMOS CONVERTIR CADENA EN NUMERO
Dim Ide As Integer = Convert.ToInt32(Id)
' Dim Time As Double = Convert.ToDouble(Tiempo)
'2.NECESITAMOS UNA CONEXION
Dim Conexion As New OleDb.OleDbConnection
Conexion.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Nino\Documents\Visual Studio 2013\Projects\Intento Tiempos1\TiemposBBDD\Tiempos.accdb;Persist Security Info =False"
'3.NECESITAMOS UNA CADENA SQL DE MENSAJERO
Dim CadenaSQL As String = "UPDATE Cronometraje SET "
'CadenaSQL += " t1 = " & Time & ""
'CadenaSQL += " WHERE id = " & Ide & ""
'4.NECESITAMOS CREAR UN COMANDO QUE CONTENGA LA INSTRUCCION DE TIPO SQL
Dim Comando As OleDbCommand = Conexion.CreateCommand()
Comando.CommandText = CadenaSQL
'5.NECESITAMOS EJECUTAR LA CONSULTA DE ACCION
Try
Conexion.Open()
Comando.ExecuteNonQuery()
Conexion.Close()
suma()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Return True
End Function
Agradezco de antemano cualquier tipo de ayuda. Muchas gracias!
Hasta esta mañana estaba usando la variable T1 como integer, pero me di cuenta que tambien necesitaba decimales asique cambie el tipo de variable tanto en la tabla de access como en mi aplicacion de VB.
Sin embargo, una vez que cambio este tipo de dato ya no me funciona y me da el siguiente error.
tengo 2 textbox que recogen las dos columnas(Id y T1) , y posteriormente uso una funcion "Modificar Registro" a la cual he intentado pasarle el textbox correspondiente a T1 como string y como Double, pero no hay manera de que funcione.
Me dice que hay un error en la instruccion update de tipo System.Data.OleDbException (0x80040E14) :Error de sintaxis en la instruccion UPDATE.
A continuacon muestro mi funcion utilizada:
Function Modificar_Tiempo(ByVal Id As String, ByVal Tiempo As Double) As Boolean
'1.NECESITAMOS CONVERTIR CADENA EN NUMERO
Dim Ide As Integer = Convert.ToInt32(Id)
' Dim Time As Double = Convert.ToDouble(Tiempo)
'2.NECESITAMOS UNA CONEXION
Dim Conexion As New OleDb.OleDbConnection
Conexion.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Nino\Documents\Visual Studio 2013\Projects\Intento Tiempos1\TiemposBBDD\Tiempos.accdb;Persist Security Info =False"
'3.NECESITAMOS UNA CADENA SQL DE MENSAJERO
Dim CadenaSQL As String = "UPDATE Cronometraje SET "
'CadenaSQL += " t1 = " & Time & ""
'CadenaSQL += " WHERE id = " & Ide & ""
'4.NECESITAMOS CREAR UN COMANDO QUE CONTENGA LA INSTRUCCION DE TIPO SQL
Dim Comando As OleDbCommand = Conexion.CreateCommand()
Comando.CommandText = CadenaSQL
'5.NECESITAMOS EJECUTAR LA CONSULTA DE ACCION
Try
Conexion.Open()
Comando.ExecuteNonQuery()
Conexion.Close()
suma()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Return True
End Function
Agradezco de antemano cualquier tipo de ayuda. Muchas gracias!
Valora esta pregunta


0