Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/06/2010, 08:03
th3r0rn
 
Fecha de Ingreso: noviembre-2007
Mensajes: 504
Antigüedad: 16 años, 5 meses
Puntos: 2
problema con query con ASP ADODB

Hola, no se por que me da este error de ADODB:
ADODB.Recordset error '800a0e78'

Operation is not allowed when the object is closed.

/Mes/Asp/was2/more2.asp, line 99
Mi codigo es:
La linea que marca el error es la: do while not registros.eof(la numero 24 de este codigo acontinuacion
Código ASP:
Ver original
  1. <&#37;
  2.  
  3. dim conexion,calendar1,calendar2,registros,linea,hora,test
  4. calendar1=request.form("calendar1")
  5. calendar2=request.form("calendar2")
  6. linea=request.form("linea")
  7. Tubo=request.form("tubo")
  8. hora=request.form("hora")
  9. test=("SELECT h.hora,h.marca,h.codoptima,h.target,P.CODOPTIMA,O.CODIGO,p.hora,p.peso,p.vaso,p.fecha, o.linea,o.tubo FROM pesos as p, optimas as o,htargets as h where o.codigo = p.codOptima and o.linea = '"&linea&"' and o.tubo LIKE '"&tubo&"'  AND p.fecha Between '"&calendar1&"' AND '"&calendar2&"' AND p.hora='"&hora&"'and h.codoptima = o.codigo and h.hora='"&hora&"'")
  10.         SET conexion=Server.CreateObject("ADODB.Connection")
  11.         conexion.Open "PROVIDER=SQLOLEDB; DATA SOURCE=VALP-MESSRV02;UID=sa;PWD=messrv;DATABASE=wasp "
  12.         SET registros=Server.CreateObject("ADODB.RecordSet")
  13.         'registros.open"SELECT peso,tubo from pesos where fecha  between '"&calendar1&"' AND '"&calendar2&"'",conexion
  14.  
  15.         registros.open"SELECT h.hora AS hora1,h.marca,h.codoptima AS codoptimaT,h.target,P.CODOPTIMA,O.CODIGO,p.hora,p.peso,p.vaso,p.fecha,o.linea,o.tubo INTO #c FROM pesos AS p, optimas AS o,htargets AS h WHERE o.codigo = p.codOptima AND o.linea = '"&linea&"' AND o.tubo ='"&tubo&"' AND p.fecha BETWEEN '"&calendar1&"' AND '"&calendar2&"' AND p.hora='"&hora&"' AND h.codoptima = o.codigo AND h.hora='"&hora&"'",conexion
  16.  
  17.  
  18.  
  19.  
  20.     'EN USO-->'registros.open"SELECT h.hora,h.marca,h.codoptima,h.target,P.CODOPTIMA,O.CODIGO,p.hora,p.peso,p.vaso,p.fecha, o.linea,o.tubo FROM pesos as p, optimas as o,htargets as h where o.codigo = p.codOptima and o.linea = '"&linea&"' and o.tubo ='"&tubo&"'  AND h.fecha Between '"&calendar1&"' AND '"&calendar2&"'  AND p.fecha Between '"&calendar1&"' AND '"&calendar2&"' AND p.hora='"&hora&"'and h.codoptima = o.codigo and h.hora='"&hora&"'" ,conexion
  21.     'registros.open"SELECT p.hora,p.peso,p.vaso,p.fecha, o.linea,o.tubo FROM pesos as p, optimas as o where o.codigo = p.codOptima and o.linea = 'L15N' and o.tubo LIKE '%'  AND p.fecha Between '2010-06-14 09:00:00.000' AND '2010-06-14 09:30:00.000' AND p.hora='9:00 - 9:30'" ,conexion    
  22.     'SELECT h.codoptima,h.target,P.CODOPTIMA,O.CODIGO,p.hora,p.peso,p.vaso,p.fecha, o.linea,o.tubo,o.codigo FROM pesos as p, optimas as o,htargets as h where o.codigo = p.codOptima and o.linea = 'L07N' and o.tubo LIKE '%' AND p.fecha Between '2010-06-14 09:30' AND '2010-06-14 10:00' AND p.hora='9:30 - 10:00' and h.codoptima = o.codigo
  23. dim a
  24.     do while not registros.eof
  25. a=cint(registros.fields("target"))
  26.  
  27.         response.write("<tr>")
  28.         response.write("<td>"&registros.fields("linea")&"</td>")
  29.         response.write("<td>"&registros.fields("peso")&"</td>")
  30.         response.write("<td>"&registros.fields("target")&"</td>")
  31.         'response.write("<td>"&a&"</td>")
  32.         response.write("<td>"&registros.fields("marca")&"</td>")
  33.         response.write("<td>"&registros.fields("vaso")&"</td>")
  34.         response.write("<td>"&registros.fields("tubo")&"</td>")
  35.         response.write("<td>"&registros.fields("fecha")&"</td>")
  36.         registros.movenext
  37.  
  38.  
  39. loop
  40.  
  41. conexion.close
  42. 'response.write(test) '<--Test Debug
  43. 'RESPONSE.WRITE("<br>")
  44.     dim codoptima
  45.  
  46. if  linea="L01N" AND tubo="A" then
  47.             codoptima=30
  48. elseif _
  49.     linea="L01N" AND tubo="B" then
  50.             codoptima=31
  51. elseif  linea="L01N" AND tubo="C" then
  52.             codoptima=32
  53. elseif  linea="L01S" AND tubo="D" then
  54.             codoptima=33
  55. elseif  linea="L01S" AND tubo="E" then
  56.             codoptima=34
  57. elseif  linea="L01S" AND tubo="F" then
  58.             codoptima=35
  59.            
  60. elseif  linea="L02N" AND tubo="A"   then
  61.             codoptima=54
  62. elseif  linea="L02N" AND tubo="B" then
  63.             codoptima=55
  64. elseif  linea="L02N" AND tubo="C" then
  65.             codoptima=56
  66.                        
  67. elseif  linea="L02N" AND tubo="D" then
  68.             codoptima=57
  69. elseif  linea="L02N" AND tubo="E" then
  70.             codoptima=58
  71. elseif  linea="L02N" AND tubo="F" then
  72.             codoptima=59
  73.    
  74. elseif  linea="L03N" AND tubo="A"   then
  75.             codoptima=60
  76. elseif  linea="L03N" AND tubo="B"   then
  77.             codoptima=61
  78. elseif  linea="L03N" AND tubo="C"   then
  79.             codoptima=62       
  80.            
  81. elseif  linea="L03S" AND tubo="D"   then
  82.             codoptima=63
  83. elseif  linea="L03S" AND tubo="E"   then
  84.             codoptima=64
  85. elseif  linea="L03S" AND tubo="F"    then
  86.             codoptima=65
  87.            
  88. elseif  linea="L06N" AND tubo="A"   then
  89.             codoptima=36
  90. elseif  linea="L06N" AND tubo="B"       then
  91.             codoptima=37
  92. elseif  linea="L06N" AND tubo="C"       then
  93.             codoptima=38
  94.            
  95. elseif  linea="L06S" AND tubo="D"       then
  96.             codoptima=39
  97. elseif  linea="L06S" AND tubo="E"       then
  98.             codoptima=40
  99. elseif  linea="L06S" AND tubo="F"       then
  100.             codoptima=41           
  101.        
  102. elseif  linea="L07N" AND tubo="A"       then
  103.             codoptima=42
  104. elseif  linea="L07N" AND tubo="B"       then
  105.             codoptima=43
  106. elseif  linea="L07N" AND tubo="C"       then
  107.             codoptima=44
  108. elseif  linea="L07S" AND tubo="D"       then
  109.             codoptima=45
  110. elseif  linea="L07S" AND tubo="E"       then
  111.             codoptima=46
  112. elseif  linea="L07S" AND tubo="F"       then
  113.             codoptima=47                   
  114. elseif  linea="L09N" AND tubo="A"       then
  115.             codoptima=48
  116. elseif  linea="L09N" AND tubo="B"       then
  117.             codoptima=49
  118. elseif  linea="L09N" AND tubo="C"       then
  119.             codoptima=50   
  120. elseif  linea="L09S" AND tubo="D"       then
  121.             codoptima=51
  122. elseif  linea="L09S" AND tubo="E"       then
  123.             codoptima=52
  124. elseif  linea="L09S" AND tubo="F"       then
  125.             codoptima=53       
  126. elseif  linea="L14N" AND tubo="A"       then
  127.             codoptima=76
  128. elseif  linea="L15N" AND tubo="A"       then
  129.             codoptima=82
  130. elseif  linea="L15N" AND tubo="B"       then
  131.             codoptima=83
  132. elseif  linea="L15N" AND tubo="C"       then
  133.             codoptima=84
  134. elseif  linea="L15S" AND tubo="D"       then
  135.             codoptima=85
  136. elseif  linea="L15S" AND tubo="E"       then
  137.             codoptima=86
  138. elseif  linea="L15S" AND tubo="F"       then
  139.             codoptima=87
  140. elseif      linea="L16N" AND tubo="A"   then
  141.             codoptima=88
  142. elseif  linea="L16N" AND tubo="B"       then
  143.             codoptima=89
  144. elseif  linea="L16N" AND tubo="C"       then
  145.             codoptima=90
  146. elseif  linea="L16S" AND tubo="D"       then
  147.             codoptima=91
  148. elseif  linea="L16S" AND tubo="E"       then
  149.             codoptima=92
  150. elseif  linea="L16S" AND tubo="F"       then
  151.             codoptima=93           
  152. elseif  linea="L17N" AND tubo="A"       then
  153.             codoptima=94
  154. elseif  linea="L17N" AND tubo="B"       then
  155.             codoptima=95
  156. elseif  linea="L17N" AND tubo="C"       then
  157.             codoptima=96
  158. elseif  linea="L17S" AND tubo="D"       then
  159.             codoptima=97
  160. elseif  linea="L17S" AND tubo="E"       then
  161.             codoptima=98
  162. elseif  linea="L17S" AND tubo="F"       then
  163.             codoptima=99
  164. elseif  linea="L19N" AND tubo="A"       then
  165.             codoptima=104
  166. elseif  linea="L19N" AND tubo="B"       then
  167.             codoptima=102
  168. elseif  linea="L19N" AND tubo="C"       then
  169.             codoptima=103          
  170.        
  171.     end if     
  172.  
  173.  
  174.             'SELECT p.peso,p.tubo,p.fecha, o.linea FROM pesos as p, optimas as o where o.codigo = p.codOptima and o.linea = 'L02N'  AND p.fecha Between '2010-05-11 09:42:34.000' AND '2010-05-11 09:42:39.000'
  175.             SET conexion2=Server.CreateObject("ADODB.Connection")
  176.             conexion2.Open "PROVIDER=SQLOLEDB; DATA SOURCE=VALP-MESSRV02;UID=sa;PWD=messrv;DATABASE=wasp "
  177.             SET registros2=Server.CreateObject("ADODB.RecordSet")
  178.        
  179.         registros2.open"SELECT AVG(PESO)as peso from pesos where fecha Between '"&calendar1&"' AND '"&calendar2&"'AND hora='"&hora&"' AND codoptima='"&codoptima&"'",conexion2
  180.         'RESPONSE.WRITE("SELECT AVG(PESO)as peso from pesos where fecha Between '"&calendar1&"' AND '"&calendar2&"'AND hora='"&hora&"' AND codoptima='"&codoptima&"'")
  181.         do while not registros2.eof
  182.         c=cint(registros2.fields("peso"))
  183.         b=(a-c)/a
  184.         response.write("Promedio: "&registros2.fields("peso")&"")
  185.     '############## Aritmetica ####################
  186.     ' C = Promedio  WHERE B=(a-c)/a
  187.     ' A = Target
  188.         response.write("<br> Op: "&b&"<br>")
  189.            
  190.         saving=(c-a)
  191.        
  192.         registros2.movenext
  193.     loop
  194.        
  195.         conexion2.close
  196.        
  197. %>
Espero puedan hecharme una manita :(