Ayuda Urgente recorrer tabla en sql y modificar el registro i seguir recorriendo la tabla
hola compa,
necesito una ayuda;
hace poco me pase a trabajar sobre codigo en sql desde visual basic, inclusive tengo rutinas ya probadas sobre : ( Insertar, modificar, borrar de una tabla registros, etc )
tengo modulos y bien y estoy contento ya he hecho aplicaciones (sobre todo como lectura de datos y grabacion , modificacion y elimicacion de todo un registro)
PERO........
quiero recorrer una tabla (while) hasta que finalice y ir modificando registro de acuerdo algunos calculos que haga o que busque otro dato en otra tabla al preguntar(if) el dato y luego modificarel regristro en que estoy y seguir con el siguiente y modificar y asi hasta termina esta tabla.
le adiciono el codigo de conexion al motor de base de datos y me ayuda porfa y hablamos que le doy a cambio, pues tengo rutinitas buenas OK ?????
CONCLUSION = visual basic con base de datos SQL me conecto con DSN y bien pero como recorro la base y la modifico al mismo tiempo que la recorre.
Private Sub MDIForm_DblClick()
On Error GoTo MDIError
Comando.Filter = "*.BMP|*.BMP|*.JGP|*.JGP|*.DIB|*.DIB|*.GIF|*.GIF|Todos los archivos|*.*"
Comando.FilterIndex = 1
Comando.ShowOpen
If Comando.CancelError = True Then GoTo MDIError
Me.Picture = LoadPicture(Comando.FileName)
Call SaveSetting("ValSalud", "general", "PICTURE", Comando.FileName)
Exit Sub
MDIError:
Select Case Err
Case 0 To 20: Resume Next
Case Else: Mensaje "Error N潞 " & Err & " " & Error$
Exit Sub
End Select
End Sub
Private Sub MDIForm_Load()
app.HelpFile = app.Path + "helphospi.hlp"
ProgName = "Sistema de informaci贸n de Validacion de Datos en Salud"
Me.Caption = ProgName
Me.Top = 0
Me.Left = 0
Me.WindowState = 2
Call InitApp
Call InitAppVars
Call MnuAbrir_Click
InicioMes = Mid(Hoy, 1, 6) & "01"
End Sub
Private Sub MnuAbrir_Click()
Dim Result As Integer
Dim Pintura As String
Puntero 11
Call MsgLin("Estableciendo conexi贸n con la base de datos ...")
DATABASE = LeerRegistro("ValSalud", "general", "DATABASE")
Call SetBDParams(DATABASE, TBD_SQL)
ServName = LeerRegistro("ValSalud", "general", "Servidor")
DSN = LeerRegistro("ValSalud", "general", "DSN")
UID = LeerRegistro("ValSalud", "general", "UID")
PWD = LeerRegistro("ValSalud", "general", "PWD")
PathRPT = LeerRegistro("ValSalud", "general", "PathRPT")
ConexionCristal = "DSN=" + DSN + ";UID=" + UID + ";PWD=" + PWD + ";DSQ=" + ServName
Pintura = GetSetting(AppName:="ValSalud", section:="general", key:="PICTURE", Default:="")
If Pintura <> NUL$ Then
Me.Picture = LoadPicture(Pintura)
End If
Result = Conexion_ODBC
If Result = FAIL Then
ReDim Datos(2)
Datos(0) = "ValSalud"
Datos(1) = "general"
Datos(2) = ""
NroParametros = 2
Mensaje ("Fallo la conexion con el servidor")
Puntero 0
FrmRegistro.Show
End
End If
Call MsgLin("Listo...")
Puntero 0
End Sub
necesito una ayuda;
hace poco me pase a trabajar sobre codigo en sql desde visual basic, inclusive tengo rutinas ya probadas sobre : ( Insertar, modificar, borrar de una tabla registros, etc )
tengo modulos y bien y estoy contento ya he hecho aplicaciones (sobre todo como lectura de datos y grabacion , modificacion y elimicacion de todo un registro)
PERO........
quiero recorrer una tabla (while) hasta que finalice y ir modificando registro de acuerdo algunos calculos que haga o que busque otro dato en otra tabla al preguntar(if) el dato y luego modificarel regristro en que estoy y seguir con el siguiente y modificar y asi hasta termina esta tabla.
le adiciono el codigo de conexion al motor de base de datos y me ayuda porfa y hablamos que le doy a cambio, pues tengo rutinitas buenas OK ?????
CONCLUSION = visual basic con base de datos SQL me conecto con DSN y bien pero como recorro la base y la modifico al mismo tiempo que la recorre.
Private Sub MDIForm_DblClick()
On Error GoTo MDIError
Comando.Filter = "*.BMP|*.BMP|*.JGP|*.JGP|*.DIB|*.DIB|*.GIF|*.GIF|Todos los archivos|*.*"
Comando.FilterIndex = 1
Comando.ShowOpen
If Comando.CancelError = True Then GoTo MDIError
Me.Picture = LoadPicture(Comando.FileName)
Call SaveSetting("ValSalud", "general", "PICTURE", Comando.FileName)
Exit Sub
MDIError:
Select Case Err
Case 0 To 20: Resume Next
Case Else: Mensaje "Error N潞 " & Err & " " & Error$
Exit Sub
End Select
End Sub
Private Sub MDIForm_Load()
app.HelpFile = app.Path + "helphospi.hlp"
ProgName = "Sistema de informaci贸n de Validacion de Datos en Salud"
Me.Caption = ProgName
Me.Top = 0
Me.Left = 0
Me.WindowState = 2
Call InitApp
Call InitAppVars
Call MnuAbrir_Click
InicioMes = Mid(Hoy, 1, 6) & "01"
End Sub
Private Sub MnuAbrir_Click()
Dim Result As Integer
Dim Pintura As String
Puntero 11
Call MsgLin("Estableciendo conexi贸n con la base de datos ...")
DATABASE = LeerRegistro("ValSalud", "general", "DATABASE")
Call SetBDParams(DATABASE, TBD_SQL)
ServName = LeerRegistro("ValSalud", "general", "Servidor")
DSN = LeerRegistro("ValSalud", "general", "DSN")
UID = LeerRegistro("ValSalud", "general", "UID")
PWD = LeerRegistro("ValSalud", "general", "PWD")
PathRPT = LeerRegistro("ValSalud", "general", "PathRPT")
ConexionCristal = "DSN=" + DSN + ";UID=" + UID + ";PWD=" + PWD + ";DSQ=" + ServName
Pintura = GetSetting(AppName:="ValSalud", section:="general", key:="PICTURE", Default:="")
If Pintura <> NUL$ Then
Me.Picture = LoadPicture(Pintura)
End If
Result = Conexion_ODBC
If Result = FAIL Then
ReDim Datos(2)
Datos(0) = "ValSalud"
Datos(1) = "general"
Datos(2) = ""
NroParametros = 2
Mensaje ("Fallo la conexion con el servidor")
Puntero 0
FrmRegistro.Show
End
End If
Call MsgLin("Listo...")
Puntero 0
End Sub