Ingresar consulta de Sql a formulario Vb6.0
Publicado por Tano (1 intervención) el 04/09/2012 16:29:08
Hola. disculpen las molestias que pueda ocacionar, estoy queriendo hacer un formulario en visual basic 6.0 conectado a una base Sql, el problema que tengo es que el insert no esta funcionando y queria ver si alguien me puede decir donde esta el error. desde ya muchas gracias
Private Sub cmdGuardar_Click(Index As Integer)
Dim consultainsert1 As String
Dim consultainsert2 As String
Dim consultainsertfinal As String
Dim consultaupdate1 As String
Dim consultaupdate2 As String
Dim consultaupdatefinal As String
'Agrega el registro
'''''''''''''''''''''''''''''''
If ValidaDatos Then
If TextEditar.Text = "editar" Then
If MsgBox("Se va a editar EL Paciente: " & vbNewLine & _
String(50, "-") & vbNewLine & _
"Nº Historia Clinica: " & Text1(0).Text & vbNewLine & _
"Apellido y Nombre: " & Text1(3).Text & vbNewLine & _
vbExclamation + vbYesNo, "Actualizar") = vbYes Then
consultaupdate1 = "UPDATE PACIENTE set Id_Paciente = '" & Text1(0) & _
"'Nombre_pa = '" & Text1(3) & _
"'Domicilio_pa = '" & Text1(8) & _
"'Localidad_pa = '" & Text1(7) & _
"'TelefonoCasa_pa = '" & Text1(5) & _
"'Celular_pa = '" & Text1(1) & _
"'Email_pa = '" & Text1(4) & _
"'CodObraSocial_pa = '" & Cmb(0).ItemData(Cmb(0).ListIndex) & _
"'NroAfiliado_pa = '" & Text1(13) & _
"'CodMedico_pa = '" & Cmb(7).ItemData(Cmb(6).ListIndex) & _
"'CodDeriva_pa = '" & Cmb(6).ItemData(Cmb(5).ListIndex) & _
"'FechaNac_pa = '" & Text1(2) & _
"'Emergencias_pa = '" & Text1(9) & _
"'Ocupacion_pa = '" & Text1(10) & _
"'Conyuge_pa = '" & Text1(11) & "'"
consultaupdate2 = "'IdEstadoCivil_pa = '" & Cmb(4).ItemData(Cmb(7).ListIndex) & _
"'IdEstudios_pa = '" & Cmb(3).ItemData(Cmb(4).ListIndex) & _
"'IdReligion_pa = '" & Cmb(2).ItemData(Cmb(3).ListIndex) & _
"'IdGrupoSangre_pa = '" & Cmb(5).ItemData(Cmb(2).ListIndex) & _
"'Sexo_pa = '" & Cmb(1).ItemData(Cmb(1)) & _
"'Diabetes_pa = '" & Check(1).Value & _
"'Alergias_pa = '" & Check(4).Value & _
"'Vih_pa = '" & Check(0).Value & _
"'TensionOcular_pa = '" & Check(2).Value & _
"'TensionArterial_pa = '" & Check(3).Value & _
"'DescripcionAlerg_pa = '" & Text1(14) & _
"' where id_paciente = '" & Text1(0) & "'"
consultaupdatefinal = consultaupdate1 & consultaupdate2
objCn.Execute consultaupdatefinal
Call CargarListView(LV, GetRs("select * from PACIENTE "))
End If
Else
consultainsert1 = "INSERT INTO PACIENTE " & "(Id_paciente,Nombre_pa,Domicilio_pa,Localidad_pa,TelefonoCasa_pa,Celular_pa,Email_pa,CodObraSocial_pa,NroAfiliado_pa,CodMedico_pa,CodDeriva_pa,FechaNac_pa,Emergencias_pa,Ocupacion_pa,Conyuge_pa,IdEstadoCivil_pa,IdEstudios_pa,IdReligion_pa,IdGrupoSangre_pa,Sexo_pa,Diabetes_pa,Alergias_pa,Vih_pa,TensionOcular_pa,TensionArterial_pa,DescripcionAlerg_pa) VALUES ('" & _
Text1(0).Text & "','" & _
Text1(3).Text & "','" & _
Text1(8).Text & "','" & _
Text1(7).Text & "','" & _
Text1(5).Text & "','" & _
Text1(1).Text & "','" & _
Text1(4).Text & "','" & _
Cmb(0).ItemData(Cmb(0).ListIndex) & "','" & _
Text1(13).Text & "','" & _
Cmb(7).ItemData(Cmb(7).ListIndex) & "','" & _
Cmb(6).ItemData(Cmb(6).ListIndex) & "','" & _
Text1(2).Text & "','" & _
Text1(9).Text & "','" & _
Text1(10).Text & "','" & _
Text1(11).Text & "','" & "',)"
consultainsert2 = Cmb(4).ItemData(Cmb(4).ListIndex) & "','" & _
Cmb(3).ItemData(Cmb(3).ListIndex) & "','" & _
Cmb(2).ItemData(Cmb(2).ListIndex) & "','" & _
Cmb(5).ItemData(Cmb(5).ListIndex) & "','" & _
Cmb(1).ItemData(Cmb(1).ListIndex) & "','" & _
Check(1).Value & "','" & _
Check(4).Value & "','" & _
Check(0).Value & "','" & _
Check(2).Value & "','" & _
Check(3).Value & "','" & _
Text1(14).Text & "','" & "')"
consultainsertfinal = consultainsert1 & consultainsert2
objCn.Execute consultainsertfinal
Call CargarListView(LV, GetRs("select * from PACIENTE "))
End If
End If
Frame1.Visible = False
End Sub
Private Sub cmdGuardar_Click(Index As Integer)
Dim consultainsert1 As String
Dim consultainsert2 As String
Dim consultainsertfinal As String
Dim consultaupdate1 As String
Dim consultaupdate2 As String
Dim consultaupdatefinal As String
'Agrega el registro
'''''''''''''''''''''''''''''''
If ValidaDatos Then
If TextEditar.Text = "editar" Then
If MsgBox("Se va a editar EL Paciente: " & vbNewLine & _
String(50, "-") & vbNewLine & _
"Nº Historia Clinica: " & Text1(0).Text & vbNewLine & _
"Apellido y Nombre: " & Text1(3).Text & vbNewLine & _
vbExclamation + vbYesNo, "Actualizar") = vbYes Then
consultaupdate1 = "UPDATE PACIENTE set Id_Paciente = '" & Text1(0) & _
"'Nombre_pa = '" & Text1(3) & _
"'Domicilio_pa = '" & Text1(8) & _
"'Localidad_pa = '" & Text1(7) & _
"'TelefonoCasa_pa = '" & Text1(5) & _
"'Celular_pa = '" & Text1(1) & _
"'Email_pa = '" & Text1(4) & _
"'CodObraSocial_pa = '" & Cmb(0).ItemData(Cmb(0).ListIndex) & _
"'NroAfiliado_pa = '" & Text1(13) & _
"'CodMedico_pa = '" & Cmb(7).ItemData(Cmb(6).ListIndex) & _
"'CodDeriva_pa = '" & Cmb(6).ItemData(Cmb(5).ListIndex) & _
"'FechaNac_pa = '" & Text1(2) & _
"'Emergencias_pa = '" & Text1(9) & _
"'Ocupacion_pa = '" & Text1(10) & _
"'Conyuge_pa = '" & Text1(11) & "'"
consultaupdate2 = "'IdEstadoCivil_pa = '" & Cmb(4).ItemData(Cmb(7).ListIndex) & _
"'IdEstudios_pa = '" & Cmb(3).ItemData(Cmb(4).ListIndex) & _
"'IdReligion_pa = '" & Cmb(2).ItemData(Cmb(3).ListIndex) & _
"'IdGrupoSangre_pa = '" & Cmb(5).ItemData(Cmb(2).ListIndex) & _
"'Sexo_pa = '" & Cmb(1).ItemData(Cmb(1)) & _
"'Diabetes_pa = '" & Check(1).Value & _
"'Alergias_pa = '" & Check(4).Value & _
"'Vih_pa = '" & Check(0).Value & _
"'TensionOcular_pa = '" & Check(2).Value & _
"'TensionArterial_pa = '" & Check(3).Value & _
"'DescripcionAlerg_pa = '" & Text1(14) & _
"' where id_paciente = '" & Text1(0) & "'"
consultaupdatefinal = consultaupdate1 & consultaupdate2
objCn.Execute consultaupdatefinal
Call CargarListView(LV, GetRs("select * from PACIENTE "))
End If
Else
consultainsert1 = "INSERT INTO PACIENTE " & "(Id_paciente,Nombre_pa,Domicilio_pa,Localidad_pa,TelefonoCasa_pa,Celular_pa,Email_pa,CodObraSocial_pa,NroAfiliado_pa,CodMedico_pa,CodDeriva_pa,FechaNac_pa,Emergencias_pa,Ocupacion_pa,Conyuge_pa,IdEstadoCivil_pa,IdEstudios_pa,IdReligion_pa,IdGrupoSangre_pa,Sexo_pa,Diabetes_pa,Alergias_pa,Vih_pa,TensionOcular_pa,TensionArterial_pa,DescripcionAlerg_pa) VALUES ('" & _
Text1(0).Text & "','" & _
Text1(3).Text & "','" & _
Text1(8).Text & "','" & _
Text1(7).Text & "','" & _
Text1(5).Text & "','" & _
Text1(1).Text & "','" & _
Text1(4).Text & "','" & _
Cmb(0).ItemData(Cmb(0).ListIndex) & "','" & _
Text1(13).Text & "','" & _
Cmb(7).ItemData(Cmb(7).ListIndex) & "','" & _
Cmb(6).ItemData(Cmb(6).ListIndex) & "','" & _
Text1(2).Text & "','" & _
Text1(9).Text & "','" & _
Text1(10).Text & "','" & _
Text1(11).Text & "','" & "',)"
consultainsert2 = Cmb(4).ItemData(Cmb(4).ListIndex) & "','" & _
Cmb(3).ItemData(Cmb(3).ListIndex) & "','" & _
Cmb(2).ItemData(Cmb(2).ListIndex) & "','" & _
Cmb(5).ItemData(Cmb(5).ListIndex) & "','" & _
Cmb(1).ItemData(Cmb(1).ListIndex) & "','" & _
Check(1).Value & "','" & _
Check(4).Value & "','" & _
Check(0).Value & "','" & _
Check(2).Value & "','" & _
Check(3).Value & "','" & _
Text1(14).Text & "','" & "')"
consultainsertfinal = consultainsert1 & consultainsert2
objCn.Execute consultainsertfinal
Call CargarListView(LV, GetRs("select * from PACIENTE "))
End If
End If
Frame1.Visible = False
End Sub
Valora esta pregunta


0