Hola a todos: tengo una aplicacion hecha en visual basic 6 que a la hora de 
guardar datos se demora 10 minutos, el codigo que utilizo es el siguiente:

 

Private Sub guardaBaseDatos(estacion As Integer)
Dim rsBd As ADODB.Recordset
Set rsBd = New Recordset
Dim rsDatos As ADODB.Recordset
Set rsDatos = New Recordset

rsDatos.Open "Select * from datos", cnl, adoenkeyset, adLockOptimistic
         
filas = 2
i = 1
cant = 0
For j = 1 To 12
        Select Case estacion
            Case 1: slotActual = msf_cadena1.TextMatrix(1, 3 + i)
            Case 2: slotActual = msf_cadena2.TextMatrix(1, 3 + i)
            Case 3: slotActual = msf_cadena3.TextMatrix(1, 3 + i)
            Case 4: slotActual = msf_cadena4.TextMatrix(1, 3 + i)
            Case 5: slotActual = msf_cadena5.TextMatrix(1, 3 + i)
            Case 6: slotActual = msf_cadena6.TextMatrix(1, 3 + i)
            Case 7: slotActual = msf_cadena7.TextMatrix(1, 3 + i)
            Case 8: slotActual = msf_cadena8.TextMatrix(1, 3 + i)
            Case 9: slotActual = msf_cadena9.TextMatrix(1, 3 + i)
           ' Case 10: slotActual = msf_cadena10.TextMatrix(1, 3 + i)
            
        End Select
        If slotActual = "N" Or slotActual = "CB" Then
          filas = filas + 1
          i = i + 1
        Else
          'rsDatos.AddNew
          Select Case estacion
            Case 1: id_estacion = msf_cadena1.TextMatrix(1, 3)
            Case 2: id_estacion = msf_cadena2.TextMatrix(1, 3)
            Case 3: id_estacion = msf_cadena3.TextMatrix(1, 3)
            Case 4: id_estacion = msf_cadena4.TextMatrix(1, 3)
            Case 5: id_estacion = msf_cadena5.TextMatrix(1, 3)
            Case 6: id_estacion = msf_cadena6.TextMatrix(1, 3)
            Case 7: id_estacion = msf_cadena7.TextMatrix(1, 3)
            Case 8: id_estacion = msf_cadena8.TextMatrix(1, 3)
            Case 9: id_estacion = msf_cadena9.TextMatrix(1, 3)
           ' Case 10: id_estacion = msf_cadena10.TextMatrix(1, 3)
            
          End Select
          On Error Resume Next
          rsBd.Open "select id_sensor, ID_tipo_sensor, slot from sensores where 
slot=" & i & " and id_estacion =" & estacion & " order by slot asc", cnl, 
adoenkeyset, adLockOptimistic
          id_tipo_sensor = rsBd.Fields(1)
          id_sensor = rsBd.Fields(0)
          rsBd.Close
          Select Case estacion
            Case 1: v_valor = msf_cadena1.TextMatrix(1, 3 + i)
            Case 2: v_valor = msf_cadena2.TextMatrix(1, 3 + i)
            Case 3: v_valor = msf_cadena3.TextMatrix(1, 3 + i)
            Case 4: v_valor = msf_cadena4.TextMatrix(1, 3 + i)
            Case 5: v_valor = msf_cadena5.TextMatrix(1, 3 + i)
            Case 6: v_valor = msf_cadena6.TextMatrix(1, 3 + i)
            Case 7: v_valor = msf_cadena7.TextMatrix(1, 3 + i)
            Case 8: v_valor = msf_cadena8.TextMatrix(1, 3 + i)
            Case 9: v_valor = msf_cadena9.TextMatrix(1, 3 + i)
            'Case 10: v_valor = msf_cadena10.TextMatrix(1, 3 + i)
          End Select
          If (v_valor) = "" Then
              valor = 0
          Else
              valor = CDbl(v_valor)
          End If
          Select Case estacion
            Case 1: v_fecha = msf_cadena1.TextMatrix(1, 1)
            Case 2: v_fecha = msf_cadena2.TextMatrix(1, 1)
            Case 3: v_fecha = msf_cadena3.TextMatrix(1, 1)
            Case 4: v_fecha = msf_cadena4.TextMatrix(1, 1)
            Case 5: v_fecha = msf_cadena5.TextMatrix(1, 1)
            Case 6: v_fecha = msf_cadena6.TextMatrix(1, 1)
            Case 7: v_fecha = msf_cadena7.TextMatrix(1, 1)
            Case 8: v_fecha = msf_cadena8.TextMatrix(1, 1)
            Case 9: v_fecha = msf_cadena9.TextMatrix(1, 1)
            'Case 10: v_fecha = msf_cadena10.TextMatrix(1, 1)
          End Select
          If v_fecha = "" Then
              fecha = "01/01/1900"
          Else
              fecha = v_fecha
           End If
          Select Case estacion
            Case 1: v_hora = msf_cadena1.TextMatrix(1, 2)
            Case 2: v_hora = msf_cadena2.TextMatrix(1, 2)
            Case 3: v_hora = msf_cadena3.TextMatrix(1, 2)
            Case 4: v_hora = msf_cadena4.TextMatrix(1, 2)
            Case 5: v_hora = msf_cadena5.TextMatrix(1, 2)
            Case 6: v_hora = msf_cadena6.TextMatrix(1, 2)
            Case 7: v_hora = msf_cadena7.TextMatrix(1, 2)
            Case 8: v_hora = msf_cadena8.TextMatrix(1, 2)
            Case 9: v_hora = msf_cadena9.TextMatrix(1, 2)
            'Case 10: v_hora = msf_cadena10.TextMatrix(1, 2)
          End Select
          
          If v_hora = "" Then
              hora = "12:00"
          Else
              hora = v_hora
          End If


          v_sql = "INSERT INTO [Datos]([ID_Estacion], [ID_Tipo_Sensor], 
[Valor], [Fecha], [Hora], dato) VALUES (" & estacion & ", " & id_tipo_sensor & 
"," & Replace(valor, ",", ".") & ", '" & fecha & "', '" & FormatDateTime(hora, 
4) & "', 0)"
          v_sqlTMP = "INSERT INTO [Datos_tmp]([ID_Estacion], id_sensor, 
[id_Tipo_Sensor], [Valor], [Fecha], [Hora], dato) VALUES (" & estacion & ", " & 
id_sensor & ", " & id_tipo_sensor & "," & Replace(valor, ",", ".") & ", '" & 
fecha & "', '" & FormatDateTime(hora, 4) & "', 0)"
          'MsgBox v_sql
       

          
          
          cnl.Execute (v_sql)
          cnl.Execute (v_sqlTMP)
          filas = filas + 1
          i = i + 1
          cant = cant + 1
        End If
Next j

End Sub

 

 

Alguien tiene idea que puede ser? donde puedo buscar?

Muchas gracias

 

Saludos

 

Carina

_________________________________________________________________
Recibe toda las noticias de actualidad al instante en tu Messenger
http://especiales.es.msn.com/noticias/msninforma.aspx 

Responder a