Daniel: no tengo indices para ninguno de los 2. El cursor que estoy usando es usuario. Hago las pruebas y cualquier cosa vuelvo a escribir. Muchas gracias. Saludos Carina
Date: Mon, 4 May 2009 15:24:12 -0300 Subject: [vbusers] Demora guardar datos From: [email protected] To: [email protected] Carina Revisa si tenes indices para: slot id_estacion La otra prueba, que cursor estas usando para la conexion? usuario o server?, proba cambiarlo, eso te puee cambiar la vida. Daniel Calvin El 4 de mayo de 2009 15:15, Carina V. Barca <[email protected]> escribió: Gracias Daniel por contestar, te cuento que puse break points y se demora una eternidad en hacer algo, se queda como esperando algo, y despues lo hace de una en un ratito (los select y los insert), por eso no tengo idea que puede ser, le puse break points a todo, incluso hice un trace para tratar de descubrir que pasa y no pude detectar que es. Voy a tener en cuenta todo lo que me aconsejas, si surge algo pregunto.Muchas graciasSaludos Carina Date: Mon, 4 May 2009 14:29:56 -0300 Subject: [vbusers] Demora guardar datos From: [email protected] To: [email protected] Hola Carina La cuestion es saber donde esta la demora.. Te fijate cuanto tarda cada select?, los predicados se benefician de algun indice o pK? Pondría un break point antes de cada select y le daria F8 para que lo ejecute, aver si la demora esta alli. Por otra parte te doy un par de consejos Deberias hacer la actualización entro de una transaction. ( si te da error a la mitad te queda actualizado solo una parte )Usaría un ebug.print now entre cada select y execute, para saber cuanto tardan Trataría de separar la rutina en un par de metodos, como para poder seguir mejor el código, asi es muy confuso. Por ejemplo esto es candidato a ser una funcion... 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 Daniel Calvin 2009/5/4 Carina V. Barca <[email protected]> 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 Más rápido, fácil, seguro y con lo que más te gusta de Windows Live, así es el nuevo Internet Explorer 8 ¡Descárgatelo! -- Daniel A. Calvin Cooperator Team Member http://www.cooperator.com.ar Microsoft Certified Professional El nuevo Windows Live tiene mucho que ofrecerte. Descúbrelo en estos vídeos -- Daniel A. Calvin Cooperator Team Member http://www.cooperator.com.ar Microsoft Certified Professional _________________________________________________________________ Descárgate ahora el nuevo Internet Explorer 8 y ten a tu alcance todos los servicios de Windows Live ¡Gratis! http://ie8.msn.com/microsoft/internet-explorer-8/es-es/ie8.aspx
