Error Expresion de criterios
Publicado por Eduan (2 intervenciones) el 29/10/2008 04:48:23
El siguiente es mi codigo y me genera el Error en la expresion de criterios.
Me señala en el codigo la fila
ObjComando.ExecuteNonQuery()
Public Class Datosbasicos
Dim Objconexion As New OleDb.OleDbConnection
Dim Sw, Accion As Byte
Private Sub Datosbasicos_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Objconexion = Conectar()
'Me va a llevar Conectar (La Conexion) a una variable declarada en la base de datos Oledbconection
Lblvalorfecha.Text = Date.Today.ToLongDateString
Cmbtipoid.Focus()
End Sub
Dim ObjComando As New OleDb.OleDbCommand
'Esta variable se define para llevar los Diferentes comandos de Adicionar, Eliminar, Etc.
'Los Comandos que yo ejecuto tienen validez sobre Access (Olebd) y sobre la base de datos que abri con ObjConexion
Private Sub BtnAdicionar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdicionar.Click
Accion = 1
Try
ObjComando.Connection = Objconexion
ObjComando.CommandText = "Insert into TblInscripcion (Valorfecha,TipoId,NumeroId,Nombres,Apellidos,FechaNacimiento,ValorEdad," & _
"Genero,Direccion,Barrio,Municipio,Medicotratante,Telefono1,Telefono2,Peso,Talla,ValorIMC,ValorCalificacionIMC,Patologia1,Patologia2," & _
"ProgramaPyP)Values ('" & Lblvalorfecha.Text & "','" & Cmbtipoid.Text & "','" & Txtnumeroid.Text & "','" & TxtNombres.Text & "'," & _
"'" & TxtApellidos.Text & "','" & MTxtfechanacimiento.Text & "','" & Lbledad.Text & "','" & CmbGenero.Text & "','" & Txtdireccion.Text & "','" & TxtBarrio.Text & "'," & _
"'" & Cmbmunicipio.Text & "','" & Txtmedicotratante.Text & "','" & Txttelefono1.Text & "','" & Txttelefono2.Text & "','" & Txtpeso.Text & "'," & _
"'" & TxtTalla.Text & "','" & LblIMC.Text & "','" & lblcalificacionimc.Text & "','" & TxtPatologia1.Text & "','" & TxtPatologia2.Text & "','" & CmbProgramaPyP.Text & "')"
'Para partir la linea Cierro comillas - Espacio - & _ y abro comillas
'Lo Siguiente se realiza Cuando Adiciono, Modifico o Elimino, pero no cuando sólo Consulto:
If Accion = 1 Then
ObjComando.ExecuteNonQuery() 'Ejecute cuando No Consulte y me inserta los valores anteriores
Else
'Es porque se fue por consultar y lo que va a hacer es traer los valores al formulario para mostrarlos.
ObjComando.CommandText = "Update TblInscripcion Set ValorFecha ='" & Lblvalorfecha.Text & "',TipoId = '" & Cmbtipoid.Text & "', Nombres = '" & TxtNombres.Text & "', " & _
" Apellidos = '" & TxtApellidos.Text & "',FechaNacimiento = '" & MTxtfechanacimiento.Text & "',ValorEdad = '" & LblValorEdad.Text & "',Genero = '" & CmbGenero.Text & "',Direccion = '" & Txtdireccion.Text & "', " & _
" Barrio = '" & TxtBarrio.Text & "',Municipio = '" & Cmbmunicipio.Text & "',Medicotratante = '" & Txtmedicotratante.Text & "',Telefono1 = '" & Txttelefono1.Text & "', " & _
" Telefono2 = '" & Txttelefono2.Text & "',Peso = '" & Txtpeso.Text & "',Talla = '" & TxtTalla.Text & "',ValorIMC = '" & LblValorIMC.Text & "', " & _
" ValorCalificacionIMC = '" & LblValorCalificacionIMC.Text & "',Patologia1 = '" & TxtPatologia1.Text & "',Patologia2 = '" & TxtPatologia2.Text & "'," & _
" ProgramaPyP = '" & CmbProgramaPyP.Text & "' where NumeroId = '" & Txtnumeroid.Text & "'"
End If
MessageBox.Show("Datos de Inscripcion Guardados")
Limpiar_campos()
Desactivar_campos()
BtnAdicionar.Enabled = False
Catch ex As Exception
MessageBox.Show(Err.Description)
End Try
Accion = 1 ' Esto es para que cuando Accion sea = a 1 me coja por este camino para adicionar uno nuevo.
Cmbtipoid.Enabled = True
Cmbtipoid.Focus()
End Sub
End Class
Me señala en el codigo la fila
ObjComando.ExecuteNonQuery()
Public Class Datosbasicos
Dim Objconexion As New OleDb.OleDbConnection
Dim Sw, Accion As Byte
Private Sub Datosbasicos_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Objconexion = Conectar()
'Me va a llevar Conectar (La Conexion) a una variable declarada en la base de datos Oledbconection
Lblvalorfecha.Text = Date.Today.ToLongDateString
Cmbtipoid.Focus()
End Sub
Dim ObjComando As New OleDb.OleDbCommand
'Esta variable se define para llevar los Diferentes comandos de Adicionar, Eliminar, Etc.
'Los Comandos que yo ejecuto tienen validez sobre Access (Olebd) y sobre la base de datos que abri con ObjConexion
Private Sub BtnAdicionar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdicionar.Click
Accion = 1
Try
ObjComando.Connection = Objconexion
ObjComando.CommandText = "Insert into TblInscripcion (Valorfecha,TipoId,NumeroId,Nombres,Apellidos,FechaNacimiento,ValorEdad," & _
"Genero,Direccion,Barrio,Municipio,Medicotratante,Telefono1,Telefono2,Peso,Talla,ValorIMC,ValorCalificacionIMC,Patologia1,Patologia2," & _
"ProgramaPyP)Values ('" & Lblvalorfecha.Text & "','" & Cmbtipoid.Text & "','" & Txtnumeroid.Text & "','" & TxtNombres.Text & "'," & _
"'" & TxtApellidos.Text & "','" & MTxtfechanacimiento.Text & "','" & Lbledad.Text & "','" & CmbGenero.Text & "','" & Txtdireccion.Text & "','" & TxtBarrio.Text & "'," & _
"'" & Cmbmunicipio.Text & "','" & Txtmedicotratante.Text & "','" & Txttelefono1.Text & "','" & Txttelefono2.Text & "','" & Txtpeso.Text & "'," & _
"'" & TxtTalla.Text & "','" & LblIMC.Text & "','" & lblcalificacionimc.Text & "','" & TxtPatologia1.Text & "','" & TxtPatologia2.Text & "','" & CmbProgramaPyP.Text & "')"
'Para partir la linea Cierro comillas - Espacio - & _ y abro comillas
'Lo Siguiente se realiza Cuando Adiciono, Modifico o Elimino, pero no cuando sólo Consulto:
If Accion = 1 Then
ObjComando.ExecuteNonQuery() 'Ejecute cuando No Consulte y me inserta los valores anteriores
Else
'Es porque se fue por consultar y lo que va a hacer es traer los valores al formulario para mostrarlos.
ObjComando.CommandText = "Update TblInscripcion Set ValorFecha ='" & Lblvalorfecha.Text & "',TipoId = '" & Cmbtipoid.Text & "', Nombres = '" & TxtNombres.Text & "', " & _
" Apellidos = '" & TxtApellidos.Text & "',FechaNacimiento = '" & MTxtfechanacimiento.Text & "',ValorEdad = '" & LblValorEdad.Text & "',Genero = '" & CmbGenero.Text & "',Direccion = '" & Txtdireccion.Text & "', " & _
" Barrio = '" & TxtBarrio.Text & "',Municipio = '" & Cmbmunicipio.Text & "',Medicotratante = '" & Txtmedicotratante.Text & "',Telefono1 = '" & Txttelefono1.Text & "', " & _
" Telefono2 = '" & Txttelefono2.Text & "',Peso = '" & Txtpeso.Text & "',Talla = '" & TxtTalla.Text & "',ValorIMC = '" & LblValorIMC.Text & "', " & _
" ValorCalificacionIMC = '" & LblValorCalificacionIMC.Text & "',Patologia1 = '" & TxtPatologia1.Text & "',Patologia2 = '" & TxtPatologia2.Text & "'," & _
" ProgramaPyP = '" & CmbProgramaPyP.Text & "' where NumeroId = '" & Txtnumeroid.Text & "'"
End If
MessageBox.Show("Datos de Inscripcion Guardados")
Limpiar_campos()
Desactivar_campos()
BtnAdicionar.Enabled = False
Catch ex As Exception
MessageBox.Show(Err.Description)
End Try
Accion = 1 ' Esto es para que cuando Accion sea = a 1 me coja por este camino para adicionar uno nuevo.
Cmbtipoid.Enabled = True
Cmbtipoid.Focus()
End Sub
End Class
Valora esta pregunta


0