Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

VB6 y SQL SERVER

Estas en el tema de VB6 y SQL SERVER en el foro de Visual Basic clásico en Foros del Web. HOLA: TENGO ESTE CODIGO QUE HACE LO SIGUIENTE: ************************************************** ********************************************* OPTION EXPLICIT Dim os_grabar as integer Dim paciente_grabar as integer Private Sub cboos_Click() os_grabar = ...
  #1 (permalink)  
Antiguo 19/10/2007, 22:15
 
Fecha de Ingreso: octubre-2007
Mensajes: 1
Antigüedad: 16 años, 6 meses
Puntos: 0
VB6 y SQL SERVER

HOLA: TENGO ESTE CODIGO QUE HACE LO SIGUIENTE:
************************************************** *********************************************
OPTION EXPLICIT
Dim os_grabar as integer
Dim paciente_grabar as integer

Private Sub cboos_Click()
os_grabar = cboos.ListIndex + 1
End Sub

Private Sub cbopaciente_Click()
paciente_grabar = cbopaciente.ListIndex + 1
End Sub

Private Sub Form_Load()
Dim recor As ADODB.Recordset
Set recor = New ADODB.Recordset
recor.Open "Select nombre_os From OBRAS_SOCIALES", bd_consultorio, adOpenStatic
For i = 1 To recor.RecordCount
cboos.AddItem recor!nombre_os
recor.MoveNext
Next i
Set recor = New ADODB.Recordset
recor.Open "Select nombre_paciente, apellido_paciente From PACIENTES", bd_consultorio, adOpenStatic
While Not recor.EOF
cbopaciente.AddItem recor("Apellido_paciente") & ", " & recor("Nombre_paciente")
recor.MoveNext
Wend
End Sub

Private Sub cmdgrabar_Click()
On Error GoTo errorsub
Select Case ACCION
Case agregar
tturnos.AddNew
tturnos(0) = txtid.Text
tturnos(1) = paciente_grabar
tturnos(2) = os_grabar
tturnos(3) = dpfecha.Value
tturnos(4) = dphora.Value
tturnos.UpdateBatch
tt.Close
tt.Open "Select TURNOS.id_turno as ID, PACIENTES.apellido_paciente as Apellido, PACIENTES.nombre_paciente as Nombre, OBRAS_SOCIALES.nombre_os as OBRA_SOCIAL, TURNOS.feCHa_atencion as FECHA_ATENCION, TURNOS.hora_atencion as HORA_ATENCION From TURNOS inner join PACIENTES ON TURNOS.id_paciente = PACIENTES.id_paciente inner join OBRA_SOCIAL_PACIENTE on PACIENTES.id_paciente = OBRA_SOCIAL_PACIENTE.id_paciente inner join OBRAS_SOCIALES on OBRA_SOCIAL_PACIENTE.id_os = OBRAS_SOCIALES.id_os order by TURNOS.id_turno", bd_consultorio
Set dgturnos.DataSource = tt
Case editar
bd_consultorio.Execute "UPDATE TURNOS set id_paciente = '" & paciente_grabar & _
"', id_os_paciente = '" & os_grabar & _
"', fecha_atencion = '" & dpfecha.Value & _
"', hora_atencion = '" & dphora.Value & _
"' where id_turno = " & txtid.Text & ""
tt.Close
tt.Open "Select TURNOS.id_turno as ID, PACIENTES.apellido_paciente as Apellido, PACIENTES.nombre_paciente as Nombre, OBRAS_SOCIALES.nombre_os as OBRA_SOCIAL, TURNOS.feCHa_atencion as FECHA_ATENCION, TURNOS.hora_atencion as HORA_ATENCION From TURNOS inner join PACIENTES ON TURNOS.id_paciente = PACIENTES.id_paciente inner join OBRA_SOCIAL_PACIENTE on PACIENTES.id_paciente = OBRA_SOCIAL_PACIENTE.id_paciente inner join OBRAS_SOCIALES on OBRA_SOCIAL_PACIENTE.id_os = OBRAS_SOCIALES.id_os order by TURNOS.id_turno", bd_consultorio
Set dgturnos.DataSource = tt
End Select
errorsub:
If Err Then
MsgBox Err.Description
End If
End Sub

Private Sub Dgturnos_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
On Error Resume Next
tturnos.Requery
tturnos.Move (tt.AbsolutePosition - 1)
LlenarLista
dgturnos.Refresh
End Sub
Public Sub LlenarLista()
If tturnos.BOF Then Exit Sub
If tturnos.EOF Then Exit Sub
Llenar txtid, tturnos, 0
Llenar cbopaciente, tturnos, 1
Llenar cboos, tturnos, 2
dpfecha.Value = IIf(IsNull(tturnos(3)), "", (tturnos(3)))
dphora.Value = IIf(IsNull(tturnos(4)), "", (tturnos(4)))
End Sub

Public Function Llenar(oText As Object, tp As ADODB.Recordset, w As Integer)
oText.Text = IIf(IsNull(tp(w)), "", tp(w))
End Function
************************************************** ********************************************
************************************************** ********************************************
EL PROBLEMA QUE TENGO ES QUE CUANDO AGO CLICK EN EL DATAGRID"Dgturnos" PARA LEVANTAR LOS DATOS EN LOS COMBOBOX ME LEVANTA EL ID_OS, EL ID_PACIENTE. Y LO QUE YO QUIERO ES QUE LEBANTE EL NOMBRE DE LA OBRA_SOIAL EN EL COMBO. EL APELLIDO,NOMBRE PACIENTE.

COMO PUEDO HACER ESTO---
SI ALGUIEN ME ENTENDIO PORFAVOR ME DE UNA RESPUESTA LO ANTES POSIBLE...........
GRACIAS!!!!!!!!!!!!!!!!!!!!!!!!
  #2 (permalink)  
Antiguo 22/10/2007, 04:41
Avatar de culd  
Fecha de Ingreso: noviembre-2003
Mensajes: 959
Antigüedad: 20 años, 6 meses
Puntos: 19
Re: VB6 y SQL SERVER

Set recor = New ADODB.Recordset
recor.Open "Select nombre_os From OBRAS_SOCIALES", bd_consultorio, adOpenStatic

Set recor = New ADODB.Recordset
recor.Open "Select nombre_paciente, apellido_paciente From PACIENTES", bd_consultorio, adOpenStatic

En ningun momento cerraste el objeto para iniciar el sergundo. No se puede abrir (crear) dos veces el mismo objeto.

osea deja solamente
recor.Open "Select nombre_paciente, apellido_paciente From PACIENTES", bd_consultorio, adOpenStatic

Me imagino que ya abriste la base de datos anteriormente.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:17.