Ver Mensaje Individual
  #7 (permalink)  
Antiguo 10/12/2009, 02:24
Avatar de neodani
neodani
 
Fecha de Ingreso: marzo-2007
Mensajes: 1.811
Antigüedad: 18 años, 2 meses
Puntos: 20
Respuesta: Error al imprimir datos de una consulta SQL

Cita:
Iniciado por JuanRAPerez Ver Mensaje
yeap

la idea báse es

creas conexión
creas el rs

haces tu sql
abres el rs
imprimes registros

haces otra sql
abres el rs con esa otra sql
imprimes registros

cierras rs
cierrras coenxion

suerte
Creo que te refererias a esto, pero me falla la última consulta

Código asp:
Ver original
  1. <%
  2.  
  3. Set conn = Server.CreateObject("ADODB.Connection")
  4. conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=xxxxxxxxxx;UID=xxxxxxx;PWD=xxxx;DATABASE=incidencias"
  5.  
  6. 'This code block will create a recordset
  7. Set rs = Server.CreateObject("ADODB.Recordset")
  8. SQL = "SELECT * FROM NSG_COMENTARIS_INCIDENCIES WHERE (creat_per = '12571') AND (YEAR(data) LIKE '2009') AND (DAY(data) LIKE '9') AND (MONTH(data) LIKE '12')"
  9. rs.open SQL, conn
  10.  
  11. 'will iterate to display the records got from the database
  12. response.write("<table class='left'>")
  13. 'response.write("<thead>" & "<th>" & "ID_Comentari" & "</th>" & "<th>" & "ID_Incidencia" & "</th>" & "<th>" & "Data" & "</th>" & "<th>" & "Descripcio" & "</th>" & "<th>" & "Temps Dedicat" & "</th>" & "<th>" & "Creat Per" & "</th>" & "</thead>")
  14. response.write("<thead>" & "<th>" & "ID_Comentari" & "</th>" & "<th>" & "ID_Incidencia" & "</th>" & "<th>" & "Data" & "</th>" & "<th>" & "Temps Dedicat" & "</th>" & "<th>" & "Creat Per" & "</th>" & "</thead>")
  15.  
  16. While Not rs.EOF
  17.   response.write("<tr>")
  18.   'response.write("<td>" & rs("id_comentari") & "</td>" & "<td>" & rs("id_incidencia") & "</td>" & "<td>" & rs("data") & "</td>" & "<td>" & rs("descripcio") & "</td>" & "<td>" & rs("temps_dedicat") & "</td>" & "<td>" & rs("creat_per") & "</td>")
  19.   response.write("<td>" & rs("id_comentari") & "</td>" & "<td>" & rs("id_incidencia") & "</td>" & "<td>" & rs("data") & "</td>" & "<td>" & rs("temps_dedicat") & "</td>" & "<td>" & rs("creat_per") & "</td>")
  20.  
  21.   response.write("</tr>")
  22.   rs.MoveNext
  23. Wend
  24. response.write("</table>")
  25. 'closes the connection
  26. 'rs.close
  27. 'conn.close
  28. 'Set rs = Nothing
  29. 'Set conn = Nothing
  30.  
  31.  
  32. 'imprimo usuarios con sus tiempos
  33. 'Set conn = Server.CreateObject("ADODB.Connection")
  34. 'conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=sqlvs1.datacenter.nexica.com;UID=pectra_tiempos;PWD=jupiter;DATABASE=Nsg_Enric"
  35.  
  36. 'Set rs = Server.CreateObject("ADODB.Recordset")
  37. 'rs.open SQL, conn
  38. SQL = "SELECT SUM(temps_dedicat) AS tiempos FROM NSG_COMENTARIS_INCIDENCIES WHERE (creat_per = '12571') AND (YEAR(data) LIKE '2009') AND (DAY(data) LIKE '9') AND (MONTH(data) LIKE '12')"
  39. rs.open SQL, conn
  40.  
  41. 'will iterate to display the records got from the database
  42. response.write("<table class='right'>")
  43. response.write("<thead>" & "<th>" & "Trabajador" & "</th>" & "<th>" & "Tiempo en Min." & "</th>" & "</thead>")
  44. While Not rs.EOF
  45.   response.write("<tr>")
  46.   response.write("<td>" & "Dani" & "</td>" & "<td>" & rs("tiempos") & "</td>")
  47.   response.write("</tr>")
  48.   rs.MoveNext
  49. Wend
  50. response.write("</table>")
  51.  
  52.  
  53. 'closes the connection
  54. rs.close
  55. conn.close
  56. Set rs = Nothing
  57. Set conn = Nothing
  58.  
  59. %
>

ADODB.Recordset error '800a0e79'
Operation is not allowed when the object is open.
/script.asp, line 115

Esa linea esta de la segunda consulta, corresponde a las linea 39 del script del post
rs.open SQL, conn

Muchas gracias de antemano!